From af49cb7bda6abb70b544d1f5fa75046071db5d93 Mon Sep 17 00:00:00 2001 From: moyongzhen <2534173414@qq.com> Date: Sat, 2 Mar 2024 14:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=BD=A8=E8=BF=B9=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackContents/TrackContentService.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 2e2b8ae7..3ffe9f33 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)); @@ -159,7 +160,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);