From d8065bb9d12906243db66ff3194be78ad4c501d2 Mon Sep 17 00:00:00 2001 From: moyongzhen <2534173414@qq.com> Date: Fri, 1 Mar 2024 17:53:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=A0=87=E8=AE=B0=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E9=80=89=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackContents/GetPageTrackContentInput.cs | 5 +++++ .../Localization/Resources/en.json | 5 ++++- .../Localization/Resources/zh.json | 5 ++++- .../Services/TrackFlags/TrackFlagService.cs | 13 ++++++++++++- .../Services/TrackStatus/TrackStatusService.cs | 13 ++++++++++++- .../TrackTemplates/TrackTemplateService.cs | 18 ++++++++++++------ .../TrackContents/GetPageTrackContentVO.cs | 5 +++++ .../Repositories/TrackContentRepository.cs | 3 ++- 8 files changed, 56 insertions(+), 11 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs index 9f7d68f2..de3844b5 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs @@ -11,6 +11,11 @@ /// 关键字 /// public string? Keywords { get; set; } + + /// + /// 选中的轨迹内容id + /// + public List? SelectIds { get; set; } } public class GetTrackContentListDto diff --git a/src/SJZY.Track.Application/Localization/Resources/en.json b/src/SJZY.Track.Application/Localization/Resources/en.json index 9e31fad8..c7d369bc 100644 --- a/src/SJZY.Track.Application/Localization/Resources/en.json +++ b/src/SJZY.Track.Application/Localization/Resources/en.json @@ -7,6 +7,9 @@ "TemplateExist": "The template code already exists under the currently selected subsystem", "TrackContentExist": "The trace code or trace content or trace content in the current subsystem is repeated in English", "TrackStatusExist": "The trajectory status code or trajectory status or trajectory status in English is repeated under the current subsystem", - "TrackFlagExist": "Duplicate code or flag in the current subsystem" + "TrackFlagExist": "Duplicate code or flag in the current subsystem", + "IsExistTrackPullConfig": "Track Pull The template has been bound. Delete the track pull before deleting the template", + "IsExistTrackStatus": "The trajectory content has been bound to the trajectory status. Delete the trajectory content before deleting the trajectory status", + "IsExistTrackFlag": "The track content has been bound to the track mark. Delete the track content before deleting the track mark" } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Localization/Resources/zh.json b/src/SJZY.Track.Application/Localization/Resources/zh.json index 24a80165..38db9ebb 100644 --- a/src/SJZY.Track.Application/Localization/Resources/zh.json +++ b/src/SJZY.Track.Application/Localization/Resources/zh.json @@ -7,6 +7,9 @@ "TemplateExist": "模板代码已存在于当前选择的子系统下", "TrackContentExist": "当前子系统下轨迹代码或轨迹内容或轨迹内容英文重复", "TrackStatusExist": "当前子系统下轨迹状态代码或轨迹状态或轨迹状态英文重复", - "TrackFlagExist": "当前子系统下代码或标记重复" + "TrackFlagExist": "当前子系统下代码或标记重复", + "IsExistTrackPullConfig": "轨迹拉取已绑定了该模版,请先删除轨迹拉取再删除该模版", + "IsExistTrackStatus": "轨迹内容已经绑定了该轨迹状态,请先删除轨迹内容后再删除该轨迹状态", + "IsExistTrackFlag": "轨迹内容已经绑定了该轨迹标记,请先删除轨迹内容后再删除该轨迹标记" } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs b/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs index a6117f0d..01e9acd4 100644 --- a/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs +++ b/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Localization; using SJZY.Track.Application.Contract.Dtos.TrackFlags; using SJZY.Track.Application.Localization; +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; using SJZY.Track.Domain.Dtos.TrackFlags; using Volo.Abp.DependencyInjection; @@ -16,14 +17,17 @@ namespace SJZY.Track.Application.Services.TrackFlags { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackFlagRepository _trackFlagRepository; + private readonly ITrackContentRepository _trackContentRepository; public TrackFlagService( IStringLocalizer stringLocalizer, - ITrackFlagRepository trackFlagRepository + ITrackFlagRepository trackFlagRepository, + ITrackContentRepository trackContentRepository ) { this._stringLocalizer = stringLocalizer; this._trackFlagRepository = trackFlagRepository; + this._trackContentRepository=trackContentRepository; } /// @@ -121,6 +125,13 @@ namespace SJZY.Track.Application.Services.TrackFlags private async Task DeleteAsync(EditTrackFlagInput input) { + #region 业务校验 + var isExistContent = await _trackContentRepository.GetFirstAsync(a => a.TrackFlagId==input.Id); + if (isExistContent!=null) + { + throw new BusinessException(message: _stringLocalizer["IsExistTrackFlag"]); + } + #endregion var isTrue = await _trackFlagRepository.SoftDeleteAsync(x => x.Id == input.Id); return new UnifyResultDto("200", "删除成功", isTrue); diff --git a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs index f7ba0720..686854db 100644 --- a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs +++ b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Localization; using SJZY.Track.Application.Contract.Dtos.TrackStatus; using SJZY.Track.Application.Localization; +using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackStatus; using Volo.Abp.DependencyInjection; @@ -16,14 +17,17 @@ public class TrackStatusService : ApplicationService, ITransientDependency { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackStatusRepository _trackStatusRepository; + private readonly ITrackContentRepository _trackContentRepository; public TrackStatusService( IStringLocalizer stringLocalizer, - ITrackStatusRepository trackStatusRepository + ITrackStatusRepository trackStatusRepository, + ITrackContentRepository trackContentRepository ) { this._stringLocalizer = stringLocalizer; this._trackStatusRepository = trackStatusRepository; + this._trackContentRepository=trackContentRepository; } /// @@ -122,6 +126,13 @@ public class TrackStatusService : ApplicationService, ITransientDependency private async Task DeleteAsync(EditTrackStatusInput input) { + #region 业务校验 + var isExistStatus = await _trackContentRepository.GetFirstAsync(a => a.TrackStatusId==input.Id); + if (isExistStatus!=null) + { + throw new BusinessException(message: _stringLocalizer["IsExistTrackStatus"]); + } + #endregion var isTrue = await _trackStatusRepository.SoftDeleteAsync(x => x.Id == input.Id); return new UnifyResultDto("200", "删除成功", isTrue); diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index 5afc3992..367f2cda 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.Localization; using SJZY.Expand.ABP.Core.Localization; using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Application.Localization; +using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackTemplate; using Volo.Abp.DependencyInjection; @@ -18,14 +19,18 @@ public class TrackTemplateService : ApplicationService, ITransientDependency { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackTemplateRepository _trackTemplateRepository; + private readonly ITrackPullConfigRepository _trackPullConfigRepository; /// public TrackTemplateService( IStringLocalizer stringLocalizer, - ITrackTemplateRepository trackTemplateRepository) + ITrackTemplateRepository trackTemplateRepository, + ITrackPullConfigRepository trackPullConfigRepository + ) { _stringLocalizer = stringLocalizer; _trackTemplateRepository = trackTemplateRepository; + _trackPullConfigRepository=trackPullConfigRepository; } /// @@ -105,14 +110,12 @@ public class TrackTemplateService : ApplicationService, ITransientDependency private async Task UpdateAsync(EditTrackTemplateInput input) { #region 业务校验 - 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: _stringLocalizer["TemplateExist"]); } - #endregion var templateEntity = await _trackTemplateRepository.GetFirstAsync(a => a.Id == input.Id); @@ -125,9 +128,12 @@ public class TrackTemplateService : ApplicationService, ITransientDependency private async Task DeleteAsync(EditTrackTemplateInput input) { #region 业务校验 - - //到时候,得判断这个模版有没有在轨迹映射里面被使用过,如果被使用就抛出提示 - + //查询看看在轨迹拉取里面有没有被占用 + var isExisistTrackPullConfig = await _trackPullConfigRepository.GetFirstAsync(a => a.TrackTemplateId==input.Id); + if (isExisistTrackPullConfig!=null) + { + throw new BusinessException(message: _stringLocalizer["IsExistTrackPullConfig"]); + } #endregion var isTrue = await _trackTemplateRepository.SoftDeleteAsync(x => x.Id == input.Id); diff --git a/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs b/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs index 4f62c3a9..f4b3c65c 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs @@ -17,6 +17,11 @@ namespace SJZY.Track.Domain.Dtos.TrackContents /// 关键字 /// public string? Keywords { get; set; } + + /// + /// 选中的轨迹内容id + /// + public List? SelectIds { get; set; } } public class GetTrackContentListVO diff --git a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs index a7bb1b6a..f177629e 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs @@ -62,7 +62,8 @@ public class TrackContentRepository : BasicRepository, ITrac (a, b, c, d, e, f) => a.Code.Contains(input.Keywords) || a.Content.Contains(input.Keywords) || a.EnContent.Contains(input.Keywords) ) - .OrderByDescending((a, b, c, d, e, f) => a.CreateTime) + .OrderByIF(input.SelectIds.IsNullOrEmpty(), (a, b, c, d, e, f) => a.CreateTime, OrderByType.Desc) + .OrderByIF(!input.SelectIds.IsNullOrEmpty(), (a, b, c, d, e, f) => SqlFunc.IIF(input.SelectIds.Contains(a.Id), SqlFunc.DateAdd(SqlFunc.GetDate(), 1), a.CreateTime), OrderByType.Desc) .Select((a, b, c, d, e, f) => new GetTrackContentListVO { Id = a.Id,