diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index 5f9bd451..65cb52d7 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -208,6 +208,9 @@ public class TrackPullService : ApplicationService, ITransientDependency [HttpPost("UpdateContent")] public async Task UpdateContentAsync([FromBody] UpdateTrackPullContentInput input) { + if (await _trackPullConfigRepository.IsContentAnyAsync(x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId && (x.TrackContentId == input.TrackContentId || x.TrackContentCodeValue == input.TrackContentCodeValue || x.TrackStatusValue == input.TrackStatusValue || x.TrackContentValue == input.TrackContentValue || x.TrackKeyword == input.TrackKeyword))) + throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]); + var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs index 0577b1cf..75aa1231 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -199,7 +199,7 @@ public class TrackPushService : ApplicationService, ITransientDependency if (input.Options != OptionTypeNoNull.删除) { Expression> isContentAnyExp = x => - x.TrackPushConfigId == input.TrackPushConfigId && x.TrackContentId == input.TrackContentId; + x.TrackPushConfigId == input.TrackPushConfigId && (x.TrackContentId == input.TrackContentId || x.TrackContentCodeValue == input.TrackContentCodeValue || x.TrackStatusValue == x.TrackStatusValue || x.TrackContentValue == input.TrackContentValue || x.TrackEnContentValue == input.TrackEnContentValue); if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id); if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp)) diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs index c7a36732..7b7dec1f 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPullAggregate/ITrackPullConfigRepository.cs @@ -48,4 +48,6 @@ public interface ITrackPullConfigRepository : IBasicRepository GetContentByIdAsync(int id); Task UpdateContentAsync(TrackPullContentConfigEntity updateObj); + + Task IsContentAnyAsync(Expression> whereExpression); } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs index f7b735be..0792d7b0 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs @@ -130,4 +130,9 @@ public class TrackPullConfigRepository : BasicRepository, { return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); } + + public async Task IsContentAnyAsync(Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).AnyAsync(); + } } \ No newline at end of file