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.
59 lines
2.4 KiB
59 lines
2.4 KiB
namespace Tiobon.Core.Services;
|
|
|
|
/// <summary>
|
|
/// 家庭关系 (服务)
|
|
/// </summary>
|
|
public class Ghrh_ResumeHomeServices : BaseServices<Ghrh_ResumeHome, Ghrh_ResumeHomeDto, InsertGhrh_ResumeHomeInput, EditGhrh_ResumeHomeInput>, IGhrh_ResumeHomeServices
|
|
{
|
|
private readonly IBaseRepository<Ghrh_ResumeHome> _dal;
|
|
public Ghrh_ResumeHomeServices(ICaching caching, IBaseRepository<Ghrh_ResumeHome> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
base._caching = caching;
|
|
}
|
|
|
|
public override async Task<List<Ghrh_ResumeHomeDto>> QueryDto(Expression<Func<Ghrh_ResumeHome, 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(async x =>
|
|
{
|
|
x.GenderLabel = await GetParaLabel("Gender", x.Gender);
|
|
x.RelationTypeLabel = await GetParaLabel("SocialRelationType", x.RelationType);
|
|
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_ResumeHomeInput> 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;
|
|
}
|
|
} |