fix:轨迹内容添加对轨迹状态、标记的校验
This commit is contained in:
parent
4f4751d7f1
commit
182c6f1cd9
@ -20,7 +20,7 @@ public class EditTrackContentInput
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属轨迹状态id
|
/// 所属轨迹状态id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TrackStatusId { get; set; }
|
public int? TrackStatusId { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 轨迹内容代码
|
/// 轨迹内容代码
|
||||||
|
|||||||
@ -5,7 +5,10 @@ using SJZY.Expand.ABP.Core.PublicMethords;
|
|||||||
using SJZY.Track.Application.Contract.Dtos.TrackContents;
|
using SJZY.Track.Application.Contract.Dtos.TrackContents;
|
||||||
using SJZY.Track.Application.Localization;
|
using SJZY.Track.Application.Localization;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
|
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.Dtos.TrackContents;
|
||||||
|
using SJZY.Track.Domain.Queries;
|
||||||
|
|
||||||
namespace SJZY.Track.Application.Services.TrackContents;
|
namespace SJZY.Track.Application.Services.TrackContents;
|
||||||
|
|
||||||
@ -18,14 +21,19 @@ public class TrackContentService : ApplicationService
|
|||||||
{
|
{
|
||||||
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
private readonly IStringLocalizer<TrackLocalizationResource> _stringLocalizer;
|
||||||
private readonly ITrackContentRepository _trackContentRepository;
|
private readonly ITrackContentRepository _trackContentRepository;
|
||||||
|
private readonly IBasicQuery<TrackFlagEntity> _trackFlagBasicQuery;
|
||||||
|
private readonly IBasicQuery<TrackStatusEntity> _trackStatusBasicQuery;
|
||||||
|
|
||||||
public TrackContentService(
|
public TrackContentService(
|
||||||
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
|
IStringLocalizer<TrackLocalizationResource> stringLocalizer,
|
||||||
ITrackContentRepository trackContentRepository
|
ITrackContentRepository trackContentRepository,
|
||||||
)
|
IBasicQuery<TrackStatusEntity> trackStatusBasicQuery,
|
||||||
|
IBasicQuery<TrackFlagEntity> trackFlagBasicQuery)
|
||||||
{
|
{
|
||||||
_stringLocalizer = stringLocalizer;
|
_stringLocalizer = stringLocalizer;
|
||||||
_trackContentRepository = trackContentRepository;
|
_trackContentRepository = trackContentRepository;
|
||||||
|
_trackStatusBasicQuery = trackStatusBasicQuery;
|
||||||
|
_trackFlagBasicQuery = trackFlagBasicQuery;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -35,6 +43,25 @@ public class TrackContentService : ApplicationService
|
|||||||
[HttpPost("Edit")]
|
[HttpPost("Edit")]
|
||||||
public async Task<UnifyResultDto> EditAsync(EditTrackContentInput input)
|
public async Task<UnifyResultDto> 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
|
return input.Options switch
|
||||||
{
|
{
|
||||||
OptionType.新增 => await AddAsync(input),
|
OptionType.新增 => await AddAsync(input),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user