This commit is contained in:
柳文翔 2024-03-02 12:42:48 +08:00
parent a9d7ab72b2
commit b21b6402e9
4 changed files with 11 additions and 1 deletions

View File

@ -208,6 +208,9 @@ public class TrackPullService : ApplicationService, ITransientDependency
[HttpPost("UpdateContent")]
public async Task<bool> 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"]);

View File

@ -199,7 +199,7 @@ public class TrackPushService : ApplicationService, ITransientDependency
if (input.Options != OptionTypeNoNull.删除)
{
Expression<Func<TrackPushContentConfigEntity, bool>> 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))

View File

@ -48,4 +48,6 @@ public interface ITrackPullConfigRepository : IBasicRepository<TrackPullConfigEn
Task<TrackPullContentConfigEntity> GetContentByIdAsync(int id);
Task<bool> UpdateContentAsync(TrackPullContentConfigEntity updateObj);
Task<bool> IsContentAnyAsync(Expression<Func<TrackPullContentConfigEntity, bool>> whereExpression);
}

View File

@ -130,4 +130,9 @@ public class TrackPullConfigRepository : BasicRepository<TrackPullConfigEntity>,
{
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
}
public async Task<bool> IsContentAnyAsync(Expression<Func<TrackPullContentConfigEntity, bool>> whereExpression)
{
return await Context.Queryable<TrackPullContentConfigEntity>().Where(whereExpression).AnyAsync();
}
}