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),