Merge pull request '修改' (#50) from S01-轨迹中台 into dev

Reviewed-on: http://192.168.80.50:3000/Dotnet/SJZY.Track.Api/pulls/50
This commit is contained in:
liuwenxiang 2024-03-05 11:19:29 +08:00
commit 53c1aa8cf8
2 changed files with 17 additions and 18 deletions

View File

@ -1,4 +1,5 @@
using System.Linq.Expressions;
using System;
using System.Linq.Expressions;
using Microsoft.Extensions.Localization;
using SJZY.Expand.ABP.Core.Localization;
using SJZY.Expand.ABP.Core.PublicMethords;
@ -209,23 +210,22 @@ public class TrackPullService : ApplicationService, ITransientDependency
[HttpPost("UpdateContent")]
public async Task<bool> UpdateContentAsync([FromBody] UpdateTrackPullContentInput input)
{
var isContentAnyExp = Expressionable.Create<TrackPullContentConfigEntity>()
.And(x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId);
Expression<Func<TrackPullContentConfigEntity, bool>> isContentAnyExp = x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId;
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId).ToExpression()))
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]);
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue).ToExpression()))
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentCodeValueAny"]);
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue).ToExpression()))
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentStatusValueAny"]);
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue).ToExpression()))
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentValueAny"]);
else if (!input.TrackKeywords.IsNullOrEmpty())
{
var trackKeywordExp = Expressionable.Create<TrackPullContentConfigEntity>();
input.TrackKeywords!.ForEach(item => { trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
Expression<Func<TrackPullContentConfigEntity, bool>> trackKeywordExp = _ => true;
input.TrackKeywords!.ForEach(item => { trackKeywordExp = trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); });
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp.ToExpression()).ToExpression()))
if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp.And(trackKeywordExp)))
throw new BusinessException(message: _stringLocalizer["IsTrackPullContentKeywordsAny"]);
}

View File

@ -202,19 +202,18 @@ public class TrackPushService : ApplicationService, ITransientDependency
{
if (input.Options != OptionTypeNoNull.删除)
{
var isContentAnyExp = Expressionable.Create<TrackPushContentConfigEntity>()
.And(x => x.TrackPushConfigId == input.TrackPushConfigId);
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp.And(x => x.Id != input.Id);
Expression<Func<TrackPushContentConfigEntity, bool>> isContentAnyExp = x => x.TrackPushConfigId == input.TrackPushConfigId;
if (input.Options == OptionTypeNoNull.修改) isContentAnyExp = isContentAnyExp.And(x => x.Id != input.Id);
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId).ToExpression()))
if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentId == input.TrackContentId)))
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]);
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue).ToExpression()))
else if (!input.TrackContentCodeValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentCodeValue == input.TrackContentCodeValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentCodeValueAny"]);
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue).ToExpression()))
else if (!input.TrackStatusValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackStatusValue == input.TrackStatusValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentStatusValueAny"]);
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue).ToExpression()))
else if (!input.TrackContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackContentValue == input.TrackContentValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPushContentValueAny"]);
else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackEnContentValue == input.TrackEnContentValue).ToExpression()))
else if (!input.TrackEnContentValue.IsNullOrWhiteSpace() && await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp.And(x => x.TrackEnContentValue == input.TrackEnContentValue)))
throw new BusinessException(message: _stringLocalizer["IsTrackPushEnContentValueAny"]);
}