From 182c6f1cd9528f76777308843bb56444e89dd1f3 Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Tue, 24 Sep 2024 15:35:55 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=BD=A8=E8=BF=B9=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=B7=BB=E5=8A=A0=E5=AF=B9=E8=BD=A8=E8=BF=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E3=80=81=E6=A0=87=E8=AE=B0=E7=9A=84=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackContents/EditTrackContentInput.cs | 2 +- .../TrackContents/TrackContentService.cs | 31 +++++++++++++++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs index 141a0bc9..6b7c663f 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs @@ -20,7 +20,7 @@ public class EditTrackContentInput /// /// 所属轨迹状态id /// - public int TrackStatusId { get; set; } + public int? TrackStatusId { get; set; } /// /// 轨迹内容代码 diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 36523ada..faf3f428 100644 --- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs +++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs @@ -5,7 +5,10 @@ using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackContents; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; +using SJZY.Track.Domain.Aggregates.TrackFlagAggregate; +using SJZY.Track.Domain.Aggregates.TrackStatusAggregate; using SJZY.Track.Domain.Dtos.TrackContents; +using SJZY.Track.Domain.Queries; namespace SJZY.Track.Application.Services.TrackContents; @@ -18,14 +21,19 @@ public class TrackContentService : ApplicationService { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackContentRepository _trackContentRepository; + private readonly IBasicQuery _trackFlagBasicQuery; + private readonly IBasicQuery _trackStatusBasicQuery; public TrackContentService( IStringLocalizer stringLocalizer, - ITrackContentRepository trackContentRepository - ) + ITrackContentRepository trackContentRepository, + IBasicQuery trackStatusBasicQuery, + IBasicQuery trackFlagBasicQuery) { _stringLocalizer = stringLocalizer; _trackContentRepository = trackContentRepository; + _trackStatusBasicQuery = trackStatusBasicQuery; + _trackFlagBasicQuery = trackFlagBasicQuery; } /// @@ -35,6 +43,25 @@ public class TrackContentService : ApplicationService [HttpPost("Edit")] public async Task EditAsync(EditTrackContentInput input) { + if (input.TrackStatusId != null) + { + if (!await _trackStatusBasicQuery.IsAnyAsync(x => + x.SubSystemId == input.SubSystemId && x.Id == input.TrackStatusId)) + { + throw new BusinessException(message: "轨迹状态不存在"); + } + } + + if (!input.TrackFlagIds.IsNullOrEmpty()) + { + var counter = await _trackFlagBasicQuery.CountAsync(x => + x.SubSystemId == input.SubSystemId && input.TrackFlagIds!.Contains(x.Id)); + if (counter != input.TrackFlagIds!.Length) + { + throw new BusinessException(message: "存在非法轨迹标记"); + } + } + return input.Options switch { OptionType.新增 => await AddAsync(input),