You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Tiobon.Web.Core/Tiobon.Core.Services/Ghrh/Ghrh_ResumeTemplateServices.cs

169 lines
9.0 KiB

using Tiobon.Core.IServices;
using Tiobon.Core.Model.Models;
using Tiobon.Core.Services.BASE;
using Tiobon.Core.IRepository.Base;
using Tiobon.Core.Common.Caches;
using Tiobon.Core.Model;
using Tiobon.Core.Common;
using Tiobon.Core.Common.Helper;
namespace Tiobon.Core.Services;
/// <summary>
/// 简历模板 (服务)
/// </summary>
public class Ghrh_ResumeTemplateServices : BaseServices<Ghrh_ResumeTemplate, Ghrh_ResumeTemplateDto, InsertGhrh_ResumeTemplateInput, EditGhrh_ResumeTemplateInput>, IGhrh_ResumeTemplateServices
{
private readonly IBaseRepository<Ghrh_ResumeTemplate> _dal;
public Ghrh_ResumeTemplateServices(ICaching caching, IBaseRepository<Ghrh_ResumeTemplate> dal)
{
this._dal = dal;
base.BaseDal = dal;
base._caching = caching;
}
#region 是否开启
public async Task<ServiceResult> SwitchPublish(long id, int? isPublish)
{
await Db.Updateable<Ghrh_ResumeTemplate>()
.SetColumns(it => new Ghrh_ResumeTemplate()
{
IsPublish = isPublish,
UpdateBy = App.User.ID,
UpdateTime = DateTime.Now
})
.Where(it => it.Id == id)
.ExecuteCommandAsync();
return ServiceResult.OprateSuccess();
}
#endregion
#region 获取分组数据
public async Task<ServiceResult<List<Ghrh_ResumeInfoGroupDto>>> QueryGroup(QueryForm filter)
{
var sql = @$"DECLARE
@MasterTemplateID INT = 0,
@TemplateType INT,
@ID BIGINT -- 母版设定ID
SELECT @ID = {filter.id}
SELECT @TemplateType = TemplateType
FROM Ghrh_ResumeTemplate
WHERE ID = @ID
SELECT @MasterTemplateID = ID
FROM Ghrh_ResumeTemplate
WHERE IsEnable = 1 AND TemplateType = 1
SELECT a.ID,
b.ID ResumeInfoGroupID,
b.GroupName ResumeInfoGroupName,
b.GroupType,
b.TableName,
b.TablePKIDName,
b.CanModifyBySelf,
b.CanEssDisplay,
CASE WHEN @TemplateType = 1 THEN 1 ELSE 0 END editable, -- 分组标题 是否可编辑
CASE
WHEN @TemplateType = 1 AND b.GroupType = 'Other' THEN 1
ELSE 0
END removable, -- 群组是否可删除
CASE
WHEN b.GroupType = 'Base' OR b.GroupType = 'Photo' THEN 0
ELSE 1
END canDrag, -- 群组是否可拖拽
CASE WHEN b.GroupType = 'Base' THEN 0 ELSE 1 END canHide, -- 群组是否可隐藏
CASE
WHEN @TemplateType = 1 AND b.GroupType ! = 'Attachment'
OR @TemplateType ! = 1 AND b.GroupType = 'Base'
THEN
1
ELSE
0
END configurable, -- 是否可挑选栏位
ISNULL (a.IsDisplay, 0) isDisplay,
isnull (a.SortNo, b.SortNo) SortNo,
-- case when ISNULL(a.IsDisplay,0)=0 then ''
CASE
WHEN 1 = 2
THEN
NULL
ELSE
CASE
WHEN b.GroupType = 'Base' -- 读取各模板设定
THEN
isnull
(
(SELECT pp.ResumeInfoColumnName,
pp.Id ResumeInfoColumnId,
pp.IsSingleColumn,
pp.DataType,
pp.ColumnType,
kk.SortNo,
pp.Placeholder,
pp.CanModifyBySelf
FROM Ghrh_ResumeTemplateInfoGroupColumn kk,
Ghrh_ResumeInfoColumn pp
WHERE kk.ResumeTemplateInfoGroupID = a.ID
AND kk.ResumeInfoColumnID = pp.ID
AND kk.IsDisplay = 1
AND pp.IsEnable = 1
AND kk.IsEnable = 1
order by kk.SortNo
FOR JSON PATH, INCLUDE_NULL_VALUES),
NULL)
WHEN b.GroupType = 'Photo' -- 读取各模板设定
THEN
(SELECT PhotoType
FROM Ghrh_ResumeTemplate
WHERE ID = @MasterTemplateID
FOR JSON PATH, INCLUDE_NULL_VALUES)
WHEN b.GroupType NOT IN ('Base', 'Photo') -- 读取母版的设定
THEN
isnull
(
(SELECT pp.ResumeInfoColumnName,
pp.Id ResumeInfoColumnId,
pp.IsSingleColumn,
pp.DataType,
pp.ColumnType,
kk.SortNo,
pp.Placeholder,
pp.CanModifyBySelf
FROM Ghrh_ResumeTemplateInfoGroupColumn kk,
Ghrh_ResumeInfoColumn pp
WHERE kk.ID = @MasterTemplateID
AND kk.ResumeInfoGroupId = b.Id
AND pp.Id = kk.ResumeInfoColumnId
AND kk.IsDisplay = 1
AND pp.IsEnable = 1
AND kk.IsEnable = 1
order by kk.SortNo
FOR JSON PATH, INCLUDE_NULL_VALUES),
NULL)
END
END GroupColumn1
FROM Ghrh_ResumeInfoGroup b
LEFT JOIN Ghrh_ResumeTemplateInfoGroup a
ON a.ResumeInfoGroupId = b.ID
AND a.IsEnable = 1 -- and a.IsDisplay=1
AND a.ResumeTemplateID = @ID
WHERE b.IsEnable = 1
-- order by ISNULL(a.IsDisplay,0) desc,isnull(a.SortNo,b.SortNo) -- 显示的放上面, 不显示的放下面, 再按照序号排序
ORDER BY a.SortNo asc -- 显示的放上面, 不显示的放下面, 再按照序号排序";
var entitys = await Db.Ado.SqlQueryAsync<Ghrh_ResumeInfoGroupDto>(sql);
entitys.ForEach(x =>
{
if (x.GroupColumn1.IsNotEmptyOrNull())
x.GroupColumn = JsonHelper.JsonToObj<List<Dictionary<string, object>>>(x.GroupColumn1);
x.GroupColumn1 = null;
});
return ServiceResult<List<Ghrh_ResumeInfoGroupDto>>.OprateSuccess("查询成功!", entitys);
}
#endregion
}