add: 增加轨迹内容分页提供获取接口【/ProviderService/Template/GetTrackTemplateListByPage】

This commit is contained in:
云龙 王 2024-12-03 18:20:01 +08:00
parent 29fbc093a3
commit fd1328ba4c
6 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1,24 @@
namespace SJZY.Track.Application.Contract.Dtos.ProvideServices;
public class GetPageTrackTemplateListInput : PageInfoInput
{
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { get; set; }
/// <summary>
/// 客户id
/// </summary>
public int? CustomerId { get; set; }
/// <summary>
/// 模版分类
/// </summary>
public int? TemplateType { get; set; }
/// <summary>
/// 模板code
/// </summary>
public string? TemplateCode { get; set; }
}

View File

@ -20,6 +20,8 @@ public class TrackTemplateAutoMapperProfile : Profile
CreateMap<GetTrackTemplateListVO, GetTrackTemplateListDto>(MemberList.None); CreateMap<GetTrackTemplateListVO, GetTrackTemplateListDto>(MemberList.None);
CreateMap<UnifyPageResultDto<GetTrackTemplateListVO>, UnifyPageResultDto<GetTrackTemplateListDto>>(MemberList CreateMap<UnifyPageResultDto<GetTrackTemplateListVO>, UnifyPageResultDto<GetTrackTemplateListDto>>(MemberList
.None); .None);
CreateMap<GetPageTrackTemplateListInput, GetPageTrackTemplateListInputVo>(MemberList.None);
CreateMap<UnifyPageResultDto<TemplateContentDtoVo>, UnifyPageResultDto<TemplateContentDto>>(MemberList.None);
CreateMap<GetTrackTemplateListInput, GetTrackTemplateListInputVo>(MemberList.None); CreateMap<GetTrackTemplateListInput, GetTrackTemplateListInputVo>(MemberList.None);
CreateMap<TrackTemplateOutputVo, TrackTemplateOutput>(MemberList.None); CreateMap<TrackTemplateOutputVo, TrackTemplateOutput>(MemberList.None);

View File

@ -33,4 +33,18 @@ public class TrackTemplateService : ApplicationService, ITrackTemplateService
var res = ObjectMapper.Map<List<TrackTemplateOutputVo>, List<TrackTemplateOutput>>(templates); var res = ObjectMapper.Map<List<TrackTemplateOutputVo>, List<TrackTemplateOutput>>(templates);
return res; return res;
} }
/// <summary>
/// 分页获取轨迹模版列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("Template/GetTrackTemplateListByPage")]
public async Task<UnifyPageResultDto<TemplateContentDto>> GetTrackTemplateListByPageAsync(GetPageTrackTemplateListInput input)
{
var inputVo = ObjectMapper.Map<GetPageTrackTemplateListInput, GetPageTrackTemplateListInputVo>(input);
var templates = await _trackTemplateRepository.GetPageTrackTemplateListAsync(inputVo);
var res = ObjectMapper.Map<UnifyPageResultDto<TemplateContentDtoVo>, UnifyPageResultDto<TemplateContentDto>>(templates);
return res;
}
} }

View File

@ -45,5 +45,6 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression); Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
Task<List<TrackTemplateOutputVo>> GetTrackTemplateListAsync(GetTrackTemplateListInputVo input); Task<List<TrackTemplateOutputVo>> GetTrackTemplateListAsync(GetTrackTemplateListInputVo input);
Task<UnifyPageResultDto<TemplateContentDtoVo>> GetPageTrackTemplateListAsync(GetPageTrackTemplateListInputVo input);
Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId); Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId);
} }

View File

@ -0,0 +1,24 @@
namespace SJZY.Track.Domain.Dtos.TrackTemplate;
public class GetPageTrackTemplateListInputVo :PageInfoInput
{
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { get; set; }
/// <summary>
/// 客户id
/// </summary>
public int? CustomerId { get; set; }
/// <summary>
/// 模版分类
/// </summary>
public int? TemplateType { get; set; }
/// <summary>
/// 模板code
/// </summary>
public string? TemplateCode { get; set; }
}

View File

@ -228,6 +228,42 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
return templates; return templates;
} }
public async Task<UnifyPageResultDto<TemplateContentDtoVo>> GetPageTrackTemplateListAsync(GetPageTrackTemplateListInputVo input)
{
var templates = await Context.Queryable<TrackTemplateEntity>()
.Where(x => x.SubSystemId == input.SubSystemId)
.WhereIF(input.CustomerId.HasValue, x => x.CustomerId == input.CustomerId)
.WhereIF(input.TemplateType.HasValue, x => x.CategoryId == input.TemplateType)
.WhereIF(!input.TemplateCode.IsNullOrWhiteSpace(), x => x.Code == input.TemplateCode)
.Select(x => new TrackTemplateOutputVo
{
Id = x.Id,
TemplateName = x.Name,
TemplateCode = x.Code,
})
.ToListAsync();
if (templates == default) return new UnifyPageResultDto<TemplateContentDtoVo>();
var templateIds = templates.Select(x => x.Id).ToArray();
var contents = await Context.Queryable<TrackTemplateContentEntity>()
.LeftJoin<TrackContentEntity>((a, b) => a.TrackContentId == b.Id)
.LeftJoin<TrackStatusEntity>((a, b, c) => b.TrackStatusId == c.Id)
.LeftJoin<TrackNodeEntity>((a, b, c, d) => c.Node == d.Id)
.Where(a => templateIds.Contains(a.TrackTemplateId))
.Select((a, b, c, d) => new TemplateContentDtoVo
{
TemplateId = a.TrackTemplateId,
Code = b.Code,
ContentCn = b.Content,
ContentEn = b.EnContent,
Status = c.Status,
Node = d.NodeName
})
.ToPagedListAsync(input.PageIndex, input.PageSize);
return contents;
}
public async Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId) public async Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId)
{ {
var sql = @$" var sql = @$"