diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/SortTrackTemplateContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/SortTrackTemplateContentInput.cs new file mode 100644 index 00000000..0dbd5155 --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackTemplates/SortTrackTemplateContentInput.cs @@ -0,0 +1,11 @@ +using SJZY.Expand.ABP.Core.PublicMethords; + +namespace SJZY.Track.Application.Contract.Dtos.TrackTemplates; + +public class SortTrackTemplateContentInput +{ + /// + /// 排序信息 + /// + public List SortInfo { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index f084dc2c..a250f22b 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.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; @@ -34,7 +35,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency _stringLocalizer = stringLocalizer; _trackTemplateRepository = trackTemplateRepository; _trackPullConfigRepository = trackPullConfigRepository; - _trackPushConfigRepository=trackPushConfigRepository; + _trackPushConfigRepository = trackPushConfigRepository; } /// @@ -119,7 +120,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency var isExist = await _trackTemplateRepository.GetFirstAsync(a => a.Id != input.Id && a.SubSystemId == input.SubSystemId && a.Code == input.Code); if (isExist != null) - { + { throw new BusinessException(message: "模板代码已存在于当前选择的子系统下"); } @@ -140,7 +141,7 @@ public class TrackTemplateService : ApplicationService, ITransientDependency var isExisistTrackPullConfigs = await _trackPullConfigRepository.GetListAsync(a => a.TrackTemplateId == input.Id); if (isExisistTrackPullConfigs.Any()) { - //throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]); + //throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]); throw new BusinessException(message: "轨迹拉取配置里已经绑定模版,请检查"); } //轨迹推送里看看是否被占用 @@ -234,4 +235,26 @@ public class TrackTemplateService : ApplicationService, ITransientDependency return true; } + + /// + /// 轨迹模板内容排序 + /// + /// + /// + [HttpPost("SortContent")] + public async Task SortContentAsync([FromBody] SortTrackTemplateContentInput input) + { + List ids = input.SortInfo.Select(x => int.Parse(x.Key)).ToList(); + + var trackTemplateContentEntities = await _trackTemplateRepository.GetContentListAsync(x => ids.Contains(x.Id)); + + trackTemplateContentEntities.ForEach(item => + { + item.Sort = input.SortInfo.Single(x => x.Key == item.Id.ToString()).Value; + }); + + await _trackTemplateRepository.UpdateContentRangeAsync(trackTemplateContentEntities); + + return true; + } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs index 13d2ff0a..3654043b 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs @@ -35,4 +35,6 @@ public interface ITrackTemplateRepository : IBasicRepository> GetContentListAsync( Expression> whereExpression); + + Task UpdateContentRangeAsync(List updateObjs); } \ 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 af67ce40..21eef31e 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -158,4 +158,9 @@ public class TrackTemplateRepository : BasicRepository, ITr { return await Context.Queryable().Where(whereExpression).ToListAsync(); } + + public async Task UpdateContentRangeAsync(List updateObjs) + { + return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync(); + } } \ No newline at end of file