From 4cd66079d08ce861fe2c628d4c68119af136b24b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Sat, 2 Mar 2024 16:21:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=20=E8=BD=A8=E8=BF=B9?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=86=85=E5=AE=B9=E4=B8=8B=E6=8B=89=E6=A1=86?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackTemplates/TrackTemplateService.cs | 12 ++++++++++++ .../ITrackTemplateRepository.cs | 5 ++++- .../GetTrackTemplateContentDropDownListVO.cs | 14 ++++++++++++++ .../GetTrackTemplateContentPageInputVO.cs | 5 ----- .../Repositories/TrackTemplateRepository.cs | 19 ++++++++++++++++--- 5 files changed, 46 insertions(+), 9 deletions(-) create mode 100644 src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index 621ae61a..1beb3bed 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -1,6 +1,7 @@ using System.Linq.Expressions; using Microsoft.Extensions.Localization; using SJZY.Expand.ABP.Core.Localization; +using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Application.Localization; @@ -183,6 +184,17 @@ public class TrackTemplateService : ApplicationService, ITransientDependency return await _trackTemplateRepository.GetContentDetailAsync(id); } + /// + /// 轨迹模板内容下拉框 + /// + /// + /// + [HttpPost("GetContentDropDownList")] + public async Task> GetContentDropDownListAsync([FromBody] GetTrackTemplateContentDropDownListVO input) + { + return await _trackTemplateRepository.GetContentDropDownListAsync(input); + } + /// /// 轨迹模板内容编辑 /// diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs index 3654043b..86e3041b 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs @@ -1,4 +1,5 @@ -using SJZY.Track.Domain.Dtos.TrackTemplate; +using SJZY.Expand.ABP.Core.PublicMethords; +using SJZY.Track.Domain.Dtos.TrackTemplate; namespace SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; @@ -37,4 +38,6 @@ public interface ITrackTemplateRepository : IBasicRepository> whereExpression); Task UpdateContentRangeAsync(List updateObjs); + + Task> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs new file mode 100644 index 00000000..ab4a6f8c --- /dev/null +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentDropDownListVO.cs @@ -0,0 +1,14 @@ +namespace SJZY.Track.Domain.Dtos.TrackTemplate; + +public class GetTrackTemplateContentDropDownListVO : PageInfoInput +{ + /// + /// 轨迹模板id + /// + public List TrackTemplateIds { get; set; } + + /// + /// 选中项 + /// + public List? SelectedIds { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs index 14b1f0ee..09e8f51f 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackTemplate/GetTrackTemplateContentPageInputVO.cs @@ -6,9 +6,4 @@ public class GetTrackTemplateContentPageInputVO : PageInfoInput /// 轨迹模板id /// public List TrackTemplateIds { get; set; } - - /// - /// 选中项 - /// - public List? SelectedIds { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs index d97ef892..ed1c75f4 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -85,8 +85,6 @@ public class TrackTemplateRepository : BasicRepository, ITr templateContent.UpdateUserId == updateUser.Id && !updateUser.IsDeleted) .Filter(null, true) .Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId) && !templateContent.IsDeleted) - .OrderByIF(input.SelectedIds.IsNullOrEmpty(), templateContent => templateContent.CreateTime, OrderByType.Desc) - .OrderByIF(!input.SelectedIds.IsNullOrEmpty(), templateContent => SqlFunc.IIF(input.SelectedIds.Contains(templateContent.TrackContentId), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), templateContent.CreateTime), OrderByType.Desc) .Select((templateContent, trackContent, trackStatus, enumValue, trackFlag, createUser, updateUser) => new GetTrackTemplateContentPageOutputVO { @@ -99,7 +97,6 @@ public class TrackTemplateRepository : BasicRepository, ITr UpdateTime = templateContent.UpdateTime, UpdateUser = updateUser.Name }, true) - .Distinct() .ToPagedListAsync(input.PageIndex, input.PageSize); } @@ -165,4 +162,20 @@ public class TrackTemplateRepository : BasicRepository, ITr { return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync(); } + + public async Task> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input) + { + return await Context.Queryable() + .InnerJoin((templateContent, trackContent) => templateContent.TrackContentId == trackContent.Id) + .Where(templateContent => input.TrackTemplateIds.Contains(templateContent.TrackTemplateId)) + .OrderByIF(input.SelectedIds.IsNullOrEmpty(), templateContent => templateContent.CreateTime, OrderByType.Desc) + .OrderByIF(!input.SelectedIds.IsNullOrEmpty(), templateContent => SqlFunc.IIF(input.SelectedIds.Contains(templateContent.TrackContentId), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), templateContent.CreateTime), OrderByType.Desc) + .Select((templateContent, trackContent) => new DropdownListDataDto + { + Value = templateContent.TrackContentId, + Key = trackContent.Code + "-" + trackContent.Content + }) + .Distinct() + .ToListAsync(); + } } \ No newline at end of file