diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs index 077f8e0a..6f3c76dd 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPull/UpdateTrackPullContentInput.cs @@ -7,7 +7,7 @@ public class UpdateTrackPullContentInput /// /// 服务商轨迹代码参数值 /// - public string TrackContentCodeValue { get; set; } + public string? TrackContentCodeValue { get; set; } /// /// 轨迹内容id @@ -17,17 +17,17 @@ public class UpdateTrackPullContentInput /// /// 服务商轨迹内容参数值 /// - public string TrackContentValue { get; set; } + public string? TrackContentValue { get; set; } /// - /// 轨迹关键词(正向) + /// 拉取轨迹关键字(正向) /// - public string TrackKeyword { get; set; } + public List? TrackKeywords { get; set; } /// - /// 轨迹关键词(反向) + /// 拉取轨迹关键字(反向) /// - public string TrackKeywordReverse { get; set; } + public List? TrackKeywordReverses { get; set; } /// /// 轨迹发生地参数值 @@ -42,7 +42,7 @@ public class UpdateTrackPullContentInput /// /// 服务商轨迹状态参数值 /// - public string TrackStatusValue { get; set; } + public string? TrackStatusValue { get; set; } /// /// 轨迹时区GMT diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs index 2af35a86..dbd0f338 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackPullAutoMapperProfile.cs @@ -12,6 +12,16 @@ public class TrackPullAutoMapperProfile : Profile CreateMap(MemberList.None); CreateMap(MemberList.None).Ignore(dest => dest.Id) .ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => false)); - CreateMap(MemberList.None); + CreateMap(MemberList.None) + .ForMember(dest => dest.TrackKeyword, opt => + { + opt.Condition(src => !src.TrackKeywords.IsNullOrEmpty()); + opt.MapFrom(src => string.Join(',', src.TrackKeywords)); + }) + .ForMember(dest => dest.TrackKeywordReverse, opt => + { + opt.Condition(src => !src.TrackKeywordReverses.IsNullOrEmpty()); + opt.MapFrom(src => string.Join(',', src.TrackKeywordReverses)); + }); } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index 65cb52d7..e78dc0ad 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -5,9 +5,11 @@ using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackPull; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; +using SJZY.Track.Domain.Aggregates.TrackPushAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.Common; using SJZY.Track.Domain.Dtos.TrackPull; +using SqlSugar; using Volo.Abp.DependencyInjection; namespace SJZY.Track.Application.Services.TrackPull; @@ -208,7 +210,16 @@ 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))) + Expression> isContentAnyExp = x => x.Id != input.Id && x.TrackPullConfigId == input.TrackPullConfigId; + + var trackKeywordExp = Expressionable.Create() + .And(x => x.TrackContentId == input.TrackContentId || x.TrackContentCodeValue == input.TrackContentCodeValue || x.TrackStatusValue == input.TrackStatusValue || x.TrackContentValue == input.TrackContentValue); + + input.TrackKeywords?.ForEach(item => { trackKeywordExp.Or(x => SqlFunc.SplitIn(x.TrackKeyword, item)); }); + + isContentAnyExp = isContentAnyExp.And(trackKeywordExp.ToExpression()); + + if (await _trackPullConfigRepository.IsContentAnyAsync(isContentAnyExp)) throw new BusinessException(message: _stringLocalizer["IsTrackPullContentAny"]); var oldTrackPullContentEntity = await _trackPullConfigRepository.GetContentByIdAsync(input.Id) ?? diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentDetailOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentDetailOutputVO.cs index f29ab75f..a4193512 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentDetailOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentDetailOutputVO.cs @@ -29,11 +29,21 @@ public class GetTrackPullContentDetailOutputVO /// public string TrackKeyword { get; set; } + /// + /// 拉取轨迹关键字(正向) + /// + public List? TrackKeywords { get; set; } + /// /// 拉取轨迹关键字(反向) /// public string TrackKeywordReverse { get; set; } + /// + /// 拉取轨迹关键字(反向) + /// + public List? TrackKeywordReverses { get; set; } + /// /// 拉取轨迹发生地 /// diff --git a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs index 50ebbe5f..a1c52026 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackPull/GetTrackPullContentPageOutputVO.cs @@ -34,21 +34,11 @@ public class GetTrackPullContentPageOutputVO /// public string? TrackKeyword { get; set; } - /// - /// 拉取轨迹关键字(正向) - /// - public List? TrackKeywords { get; set; } - /// /// 拉取轨迹关键字(反向) /// public string? TrackKeywordReverse { get; set; } - /// - /// 拉取轨迹关键字(反向) - /// - public List? TrackKeywordsReverse { get; set; } - /// /// 轨迹发生地 /// diff --git a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs index 0792d7b0..aaf3f8b9 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs @@ -45,11 +45,6 @@ public class TrackPullConfigRepository : BasicRepository, { Id = pullContent.Id }, true) - .Mapper(x => - { - x.TrackKeywords = x.TrackKeyword?.Split(',').ToList(); - x.TrackKeywordsReverse = x.TrackKeywordReverse?.Split(',').ToList(); - }) .ToPagedListAsync(input.PageIndex, input.PageSize); } @@ -82,6 +77,11 @@ public class TrackPullConfigRepository : BasicRepository, Id = pullContent.Id, Code = trackContent.Code + "-" + trackContent.Content, }, true) + .Mapper(x => + { + x.TrackKeywords = x.TrackKeyword?.Split(',').ToList(); + x.TrackKeywordsReverse = x.TrackKeywordReverse?.Split(',').ToList(); + }) .SingleAsync(); }