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.Common.DB.Dapper.Extensions;
namespace Tiobon.Core.Services
{
///
/// 考核模板 (服务)
///
public class Ghrp_PerformanceTemplateServices : BaseServices, IGhrp_PerformanceTemplateServices
{
private readonly IBaseRepository _dal;
public Ghrp_PerformanceTemplateServices(ICaching caching, IBaseRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
base._caching = caching;
}
public override async Task> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true)
{
var result = await base.QueryFilterPage(filter, condition, IsEnable);
result.result.DT_TableDataT1.ForEach(async x =>
{
x.StageItem = await GetParaLabel("PerformanceStageItem", x.StageItem);
x.MGShowType = await GetParaLabelListString("Performance", "PerformanceMGShowType", x.MGShowType);
x.TemplateType = await GetParaLabelListString("Performance", "PerformanceTemplateType", x.TemplateType);
x.StaffGroupName = Db.Ado.GetString("select StaffGroupName from Ghra_StaffGroup where StaffGroupID=@StaffGroupID"
, new { StaffGroupID = x.StaffGroupID });
x.PeriodTypeName = Db.Ado.GetString("select PeriodTypeName from Ghrp_PerformancePeriodType where PerformancePeriodTypeID=@PerformancePeriodTypeID"
, new { PerformancePeriodTypeID = x.PerformancePeriodTypeID });
});
return result;
}
public override async Task Add(InsertGhrp_PerformanceTemplateInput entity)
{
if (entity.PerformancePeriodTypeID != null)
entity.PeriodTypeNo = await Db.Queryable().Where(a => a.Id == entity.PerformancePeriodTypeID).Select(x => x.PeriodTypeNo).FirstAsync();
var result = await base.Add(entity);
return result;
}
public override async Task Update(long Id, EditGhrp_PerformanceTemplateInput editModel)
{
if (editModel.PerformancePeriodTypeID != null)
editModel.PeriodTypeNo = await Db.Queryable().Where(a => a.Id == editModel.PerformancePeriodTypeID).Select(x => x.PeriodTypeNo).FirstAsync();
var result = await base.Update(Id, editModel, null, ["Status"]);
return result;
}
}
}