From b21b6402e95fc0dafbb5df19fe91edb99457a33c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Sat, 2 Mar 2024 12:42:48 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackPull/TrackPullService.cs | 3 +++ .../Services/TrackPush/TrackPushService.cs | 2 +- .../TrackPullAggregate/ITrackPullConfigRepository.cs | 2 ++ .../Repositories/TrackPullConfigRepository.cs | 5 +++++ 4 files changed, 11 insertions(+), 1 deletion(-) 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 From 884a802481e87db022d3b4cf935e74bfd31abfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Sat, 2 Mar 2024 12:47:20 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=AD=97=E6=AE=B5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TrackPush/EditTrackPushConfigInput.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs index 06b75472..b462f6a4 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushConfigInput.cs @@ -72,7 +72,7 @@ public class EditTrackPushConfigInput /// /// 轨迹模板id /// - public List TrackTemplateIds { get; set; } + public List? TrackTemplateIds { get; set; } /// /// 推送轨迹发生时间 From fefc52638a6153cc342cf470aef57221f882b93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Sat, 2 Mar 2024 13:01:35 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/TrackTemplateRepository.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs index 0bcc56c2..d97ef892 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -99,6 +99,7 @@ public class TrackTemplateRepository : BasicRepository, ITr UpdateTime = templateContent.UpdateTime, UpdateUser = updateUser.Name }, true) + .Distinct() .ToPagedListAsync(input.PageIndex, input.PageSize); } From bed691aa71569b01ee9e9f9d2367a82366fd973f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Sat, 2 Mar 2024 13:52:51 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TrackPull/UpdateTrackPullContentInput.cs | 14 +++++++------- .../AutoMapper/TrackPullAutoMapperProfile.cs | 12 +++++++++++- .../Services/TrackPull/TrackPullService.cs | 13 ++++++++++++- .../TrackPull/GetTrackPullContentDetailOutputVO.cs | 10 ++++++++++ .../TrackPull/GetTrackPullContentPageOutputVO.cs | 10 ---------- .../Repositories/TrackPullConfigRepository.cs | 10 +++++----- 6 files changed, 45 insertions(+), 24 deletions(-) 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(); } From 046999c208bddc2c8877689ca58f9600ece76eb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Sat, 2 Mar 2024 13:54:26 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/TrackPullConfigRepository.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs index aaf3f8b9..3a381a0f 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPullConfigRepository.cs @@ -80,7 +80,7 @@ public class TrackPullConfigRepository : BasicRepository, .Mapper(x => { x.TrackKeywords = x.TrackKeyword?.Split(',').ToList(); - x.TrackKeywordsReverse = x.TrackKeywordReverse?.Split(',').ToList(); + x.TrackKeywordReverses = x.TrackKeywordReverse?.Split(',').ToList(); }) .SingleAsync(); }