add: 增加轨迹内容分页提供获取接口【/ProviderService/Template/GetTrackTemplateListByPage】
This commit is contained in:
parent
29fbc093a3
commit
fd1328ba4c
@ -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; }
|
||||
}
|
||||
@ -20,6 +20,8 @@ public class TrackTemplateAutoMapperProfile : Profile
|
||||
CreateMap<GetTrackTemplateListVO, GetTrackTemplateListDto>(MemberList.None);
|
||||
CreateMap<UnifyPageResultDto<GetTrackTemplateListVO>, UnifyPageResultDto<GetTrackTemplateListDto>>(MemberList
|
||||
.None);
|
||||
CreateMap<GetPageTrackTemplateListInput, GetPageTrackTemplateListInputVo>(MemberList.None);
|
||||
CreateMap<UnifyPageResultDto<TemplateContentDtoVo>, UnifyPageResultDto<TemplateContentDto>>(MemberList.None);
|
||||
|
||||
CreateMap<GetTrackTemplateListInput, GetTrackTemplateListInputVo>(MemberList.None);
|
||||
CreateMap<TrackTemplateOutputVo, TrackTemplateOutput>(MemberList.None);
|
||||
|
||||
@ -33,4 +33,18 @@ public class TrackTemplateService : ApplicationService, ITrackTemplateService
|
||||
var res = ObjectMapper.Map<List<TrackTemplateOutputVo>, List<TrackTemplateOutput>>(templates);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,5 +45,6 @@ public interface ITrackTemplateRepository : IBasicRepository<TrackTemplateEntity
|
||||
Expression<Func<TrackTemplateContentEntity, bool>> whereExpression);
|
||||
|
||||
Task<List<TrackTemplateOutputVo>> GetTrackTemplateListAsync(GetTrackTemplateListInputVo input);
|
||||
Task<UnifyPageResultDto<TemplateContentDtoVo>> GetPageTrackTemplateListAsync(GetPageTrackTemplateListInputVo input);
|
||||
Task<List<string>> GetContentByTemplateCodes(string[] codes, int systemId);
|
||||
}
|
||||
|
||||
@ -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; }
|
||||
}
|
||||
@ -228,6 +228,42 @@ public class TrackTemplateRepository : BasicRepository<TrackTemplateEntity>, ITr
|
||||
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)
|
||||
{
|
||||
var sql = @$"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user