namespace Tiobon.Core.Services;
///
/// 简历培训记录 (服务)
///
public class Ghrh_ResumeTrainingServices : BaseServices, IGhrh_ResumeTrainingServices
{
private readonly IBaseRepository _dal;
public Ghrh_ResumeTrainingServices(ICaching caching, IBaseRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
base._caching = caching;
}
public override async Task> QueryDto(Expression> whereExpression)
{
var data = await base.QueryDto(whereExpression);
var ids = data.Select(x => x.Id.ToString()).ToList();
var attachments = await Db.Queryable().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> Add(List listEntity)
{
var result = new List();
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()
.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;
}
}