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_ResumeTrainingServices.cs

61 lines
2.5 KiB

namespace Tiobon.Core.Services;
/// <summary>
/// 简历培训记录 (服务)
/// </summary>
public class Ghrh_ResumeTrainingServices : BaseServices<Ghrh_ResumeTraining, Ghrh_ResumeTrainingDto, InsertGhrh_ResumeTrainingInput, EditGhrh_ResumeTrainingInput>, IGhrh_ResumeTrainingServices
{
private readonly IBaseRepository<Ghrh_ResumeTraining> _dal;
public Ghrh_ResumeTrainingServices(ICaching caching, IBaseRepository<Ghrh_ResumeTraining> dal)
{
this._dal = dal;
base.BaseDal = dal;
base._caching = caching;
}
public override async Task<List<Ghrh_ResumeTrainingDto>> QueryDto(Expression<Func<Ghrh_ResumeTraining, bool>> whereExpression)
{
var data = await base.QueryDto(whereExpression);
var ids = data.Select(x => x.Id.ToString()).ToList();
var attachments = await Db.Queryable<Ghrs_Attachment>().Where(x => ids.Contains(x.TableName)).ToListAsync();
data.ForEach(x =>
{
x.BeginDate1 = DateTimeHelper.ConvertToDayString(x.BeginDate);
x.EndDate1 = DateTimeHelper.ConvertToDayString(x.EndDate);
if (x.IsPass != null)
x.IsPassLabel = x.IsPass == true ? "是" : "否";
x.AttachmentIDs = attachments
.Where(o => o.TableName == x.Id.ToString())
.Select(o => new ResumeAttachment()
{
AttachmentID = o.AttachmentID,
AttachFileExtension = o.AttachFileExtension,
AttachFileSize = o.AttachFileSize,
RelativePath = o.RelativePath,
AttachmentName = o.AttachmentName,
RemarkSz = o.RemarkSz
}).ToList();
});
return data;
}
public override async Task<List<long>> Add(List<InsertGhrh_ResumeTrainingInput> listEntity)
{
var result = new List<long>();
for (int i = 0; i < listEntity.Count; i++)
{
var id = await base.Add(listEntity[i]);
if (listEntity[i].AttachmentIDs != null && listEntity[i].AttachmentIDs.Any())
{
var ids = listEntity[i].AttachmentIDs.Select(x => x.RelativePath).ToList();
await Db.Updateable<Ghrs_Attachment>()
.SetColumns(x => new Ghrs_Attachment() { TableName = id.ToString(), UpdateTime = DateTime.Now })
.Where(it => it.AttachmentID != null && ids.Contains(it.RelativePath))
.ExecuteCommandAsync();
}
result.Add(id);
}
return result;
}
}