diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 67097d55..9c872bf2 100644 --- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs +++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs @@ -8,6 +8,7 @@ using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Dtos.TrackContents; +using SJZY.Track.Domain.Queries; using System.Linq.Expressions; using Volo.Abp.DependencyInjection; @@ -22,15 +23,17 @@ namespace SJZY.Track.Application.Services.TrackContents { private readonly IStringLocalizer _stringLocalizer; private readonly ITrackContentRepository _trackContentRepository; + private readonly IBasicQuery _trackContentMapBasicQuery; public TrackContentService( IStringLocalizer stringLocalizer, - ITrackContentRepository trackContentRepository - + ITrackContentRepository trackContentRepository, + IBasicQuery trackContentMapBasicQuery ) { this._stringLocalizer = stringLocalizer; this._trackContentRepository = trackContentRepository; + this._trackContentMapBasicQuery=trackContentMapBasicQuery; } /// @@ -99,7 +102,6 @@ namespace SJZY.Track.Application.Services.TrackContents //throw new BusinessException(message: _stringLocalizer["TrackContentExist"]); throw new BusinessException(message: "当前子系统下,轨迹代码或轨迹内容或轨迹内容英文存在"); } - #endregion 业务逻辑校验 var entity = ObjectMapper.Map(input); @@ -111,7 +113,6 @@ namespace SJZY.Track.Application.Services.TrackContents private async Task UpdateAsync(EditTrackContentInput input) { #region 业务逻辑校验 - var trackContentEntitys = await _trackContentRepository.GetListAsync(a => a.Id != input.Id && a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Content == input.Content || a.EnContent == input.EnContent)); @@ -161,7 +162,11 @@ namespace SJZY.Track.Application.Services.TrackContents #region 业务校验 //需要加个判断,存在内容映射,则出提示 - + var trackContentMapEntities = await _trackContentMapBasicQuery.GetListAsync(a => a.TrackContentId==input.Id|| a.MapTrackContentId==input.Id); + if (trackContentMapEntities.Any()) + { + throw new BusinessException(message: "无法删除该内容,该轨迹内容已在轨迹内容映射中使用了,请检查"); + } #endregion 业务校验 var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id);