From 2905b47d1a7175d4b1a88384a945c2ba176e976d Mon Sep 17 00:00:00 2001 From: moyongzhen <2534173414@qq.com> Date: Mon, 4 Mar 2024 09:26:59 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackFlags/TrackFlagService.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs b/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs index d46b6d96..bc3f68ad 100644 --- a/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs +++ b/src/SJZY.Track.Application/Services/TrackFlags/TrackFlagService.cs @@ -129,7 +129,8 @@ namespace SJZY.Track.Application.Services.TrackFlags var isExistContent = await _trackContentRepository.GetFirstAsync(a => a.TrackFlagId==input.Id); if (isExistContent!=null) { - throw new BusinessException(message: _stringLocalizer["IsExistTrackFlag"]); + //throw new BusinessException(message: _stringLocalizer["IsExistTrackFlag"]); + throw new BusinessException(message: "该标记关联轨迹内容,禁止删除"); } #endregion var isTrue = await _trackFlagRepository.SoftDeleteAsync(x => x.Id == input.Id); From 28462ffc8331b204bf7adab6e1557a7110942bbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Mon, 4 Mar 2024 10:20:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrackContents/TrackContentService.cs | 14 +++---- .../Services/TrackPull/TrackPullService.cs | 1 - .../Services/TrackPush/TrackPushService.cs | 34 ++++++++++++----- .../TrackTemplates/TrackTemplateService.cs | 37 +++++++++++++------ .../ITrackPushConfigRepository.cs | 4 ++ .../ITrackTemplateRepository.cs | 4 ++ .../Repositories/TrackPushConfigRepository.cs | 10 +++++ .../Repositories/TrackTemplateRepository.cs | 10 +++++ 8 files changed, 86 insertions(+), 28 deletions(-) diff --git a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs index 9490f1d3..cac9a7a6 100644 --- a/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs +++ b/src/SJZY.Track.Application/Services/TrackContents/TrackContentService.cs @@ -1,12 +1,9 @@ using Microsoft.Extensions.Localization; -using SJZY.Expand.ABP.Core.Common.Dto; using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackContents; -using SJZY.Track.Application.Contract.Dtos.TrackPull; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackContentAggregate; -using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackTemplateAggregate; using SJZY.Track.Domain.Dtos.TrackContents; using SJZY.Track.Domain.Queries; @@ -36,8 +33,8 @@ namespace SJZY.Track.Application.Services.TrackContents { this._stringLocalizer = stringLocalizer; this._trackContentRepository = trackContentRepository; - this._trackContentMapBasicQuery=trackContentMapBasicQuery; - this._trackTemplateContentBasicQuery=trackTemplateContentBasicQuery; + this._trackContentMapBasicQuery = trackContentMapBasicQuery; + this._trackTemplateContentBasicQuery = trackTemplateContentBasicQuery; } /// @@ -106,6 +103,7 @@ namespace SJZY.Track.Application.Services.TrackContents //throw new BusinessException(message: _stringLocalizer["TrackContentExist"]); throw new BusinessException(message: "当前子系统下,轨迹代码或轨迹内容或轨迹内容英文存在"); } + #endregion 业务逻辑校验 var entity = ObjectMapper.Map(input); @@ -117,6 +115,7 @@ namespace SJZY.Track.Application.Services.TrackContents private async Task UpdateAsync(EditTrackContentInput input) { #region 业务逻辑校验 + var trackContentEntitys = await _trackContentRepository.GetListAsync(a => a.Id != input.Id && a.SubSystemId == input.SubSystemId && (a.Code == input.Code || a.Content == input.Content || a.EnContent == input.EnContent)); @@ -166,18 +165,19 @@ namespace SJZY.Track.Application.Services.TrackContents #region 业务校验 //查询是否关联了轨迹模版内容 - var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId==input.Id); + var trackTemplateContents = await _trackTemplateContentBasicQuery.GetListAsync(a => a.TrackContentId == input.Id); if (trackTemplateContents.Any()) { throw new BusinessException(message: "该轨迹内容关联轨迹模板,禁止删除"); } //需要加个判断,存在内容映射,则出提示 - var trackContentMapEntities = await _trackContentMapBasicQuery.GetListAsync(a => a.TrackContentId==input.Id|| a.MapTrackContentId==input.Id); + var trackContentMapEntities = await _trackContentMapBasicQuery.GetListAsync(a => a.TrackContentId == input.Id || a.MapTrackContentId == input.Id); if (trackContentMapEntities.Any()) { throw new BusinessException(message: "无法删除该内容,该轨迹内容已在轨迹内容映射中使用了,请检查"); } + #endregion 业务校验 var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id); diff --git a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs index df2e40bd..f1bc092a 100644 --- a/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs +++ b/src/SJZY.Track.Application/Services/TrackPull/TrackPullService.cs @@ -5,7 +5,6 @@ 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; diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs index ff0c193d..dfdeba35 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -215,26 +215,42 @@ public class TrackPushService : ApplicationService, ITransientDependency { case OptionTypeNoNull.新增: { - var trackPushContentEntity = ObjectMapper.Map(input); + int maxSort = await _trackPushConfigRepository.ContentMaxAsync(x => x.Sort, x => x.TrackPushConfigId == input.TrackPushConfigId); - await _trackPushConfigRepository.InsertContentAsync(trackPushContentEntity); + var entity = ObjectMapper.Map(input); + entity.Sort = maxSort + 1; + + await _trackPushConfigRepository.InsertContentAsync(entity); + + break; } - break; case OptionTypeNoNull.修改: { - var oldTrackPushContentEntity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); + var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); - ObjectMapper.Map(input, oldTrackPushContentEntity); + ObjectMapper.Map(input, entity); - await _trackPushConfigRepository.UpdateContentAsync(oldTrackPushContentEntity); + await _trackPushConfigRepository.UpdateContentAsync(entity); + + break; } - break; case OptionTypeNoNull.删除: - await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id); + { + var entity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); - break; + using (var ts = TransactionScopeHelper.Create()) + { + await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id); + + await _trackPushConfigRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackPushConfigId == entity.TrackPushConfigId && x.Sort > entity.Sort); + + ts.Complete(); + } + + break; + } default: throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, diff --git a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs index 99cf36dc..831a17e0 100644 --- a/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs +++ b/src/SJZY.Track.Application/Services/TrackTemplates/TrackTemplateService.cs @@ -2,7 +2,6 @@ using Microsoft.Extensions.Localization; using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; -using SJZY.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Application.Contract.Dtos.TrackTemplates; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; @@ -216,29 +215,45 @@ public class TrackTemplateService : ApplicationService, ITransientDependency switch (input.Options) { case OptionTypeNoNull.新增: + { + int maxSort = await _trackTemplateRepository.ContentMaxAsync(x => x.Sort, x => x.TrackTemplateId == input.TrackTemplateId); - var entity = ObjectMapper.Map(input); + var entity = ObjectMapper.Map(input); + entity.Sort = maxSort + 1; - await _trackTemplateRepository.InsertContentAsync(entity); + await _trackTemplateRepository.InsertContentAsync(entity); - break; + break; + } case OptionTypeNoNull.修改: - - var oldEntity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? + { + var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); - ObjectMapper.Map(input, oldEntity); + ObjectMapper.Map(input, entity); - await _trackTemplateRepository.UpdateContentAsync(oldEntity); + await _trackTemplateRepository.UpdateContentAsync(entity); - break; + break; + } case OptionTypeNoNull.删除: + { + var entity = await _trackTemplateRepository.GetContentByIdAsync(input.Id!.Value) ?? + throw new BusinessException(message: _stringLocalizer["NotFindData"]); - await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value); + using (var ts = TransactionScopeHelper.Create()) + { + await _trackTemplateRepository.SoftDeleteContentAsync(input.Id!.Value); - break; + await _trackTemplateRepository.UpdateContentAsync(x => x.Sort == x.Sort - 1, x => x.TrackTemplateId == entity.TrackTemplateId && x.Sort > entity.Sort); + + ts.Complete(); + } + + break; + } default: throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs index 3d33a4ee..80013967 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs @@ -26,4 +26,8 @@ public interface ITrackPushConfigRepository : IBasicRepository> GetContentListAsync(Expression> whereExpression); Task UpdateContentRangeAsync(List updateObjs); + + Task ContentMaxAsync(Expression> columns, Expression> whereExpression); + + Task UpdateContentAsync(Expression> columns, Expression> whereExpression); } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs index 5c738f78..e6ab4b0b 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackTemplateAggregate/ITrackTemplateRepository.cs @@ -40,4 +40,8 @@ public interface ITrackTemplateRepository : IBasicRepository UpdateContentRangeAsync(List updateObjs); Task> GetContentDropDownListAsync(GetTrackTemplateContentDropDownListVO input); + + Task ContentMaxAsync(Expression> columns, Expression> whereExpression); + + Task UpdateContentAsync(Expression> columns, Expression> whereExpression); } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs index 29300b59..2531f141 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs @@ -124,4 +124,14 @@ public class TrackPushConfigRepository : BasicRepository, { return await Context.Updateable(updateObjs).ExecuteCommandHasChangeAsync(); } + + public async Task ContentMaxAsync(Expression> columns, Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).MaxAsync(columns); + } + + public async Task UpdateContentAsync(Expression> columns, Expression> whereExpression) + { + return await Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommandHasChangeAsync(); + } } \ No newline at end of file diff --git a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs index 37d27a78..d414e5c8 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackTemplateRepository.cs @@ -179,4 +179,14 @@ public class TrackTemplateRepository : BasicRepository, ITr .Distinct() .ToPagedListAsync(input.PageIndex, input.PageSize); } + + public async Task ContentMaxAsync(Expression> columns, Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).MaxAsync(columns); + } + + public async Task UpdateContentAsync(Expression> columns, Expression> whereExpression) + { + return await Context.Updateable().SetColumns(columns).Where(whereExpression).ExecuteCommandHasChangeAsync(); + } } \ No newline at end of file From 8e915891861f280775665a855385fb5ace5a9474 Mon Sep 17 00:00:00 2001 From: moyongzhen <2534173414@qq.com> Date: Mon, 4 Mar 2024 10:31:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=AE=8C=E7=BB=93=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TrackContents/EditTrackContentInput.cs | 10 ++++++++++ .../TrackContents/GetPageTrackContentInput.cs | 5 +++++ .../Dtos/TrackFlags/EditTrackFlagInput.cs | 16 ++++++++-------- .../Dtos/TrackFlags/GetTrackFlagListDto.cs | 8 ++++---- .../AutoMapper/TrackContentAutoMapperProfile.cs | 3 ++- .../AutoMapper/TrackFlagAutoMapperProfile.cs | 8 ++------ .../TrackContentAggregate/TrackContentEntity.cs | 6 ++++++ .../TrackFlagAggregate/TrackFlagEntity.cs | 10 +++++----- .../Dtos/TrackContents/GetPageTrackContentVO.cs | 5 +++++ .../TrackContents/GetTrackContentDetailVO.cs | 5 +++++ .../Dtos/TrackFlags/GetPageTrackFlagVO.cs | 8 ++++---- .../Dtos/TrackFlags/GetTrackFlagDetailVO.cs | 8 ++++---- .../Queries/TrackQueries.cs | 2 +- .../Repositories/TrackContentRepository.cs | 6 ++++-- .../Repositories/TrackFlagRepository.cs | 6 +++--- 15 files changed, 68 insertions(+), 38 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs index d2a829ca..f13eac46 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/EditTrackContentInput.cs @@ -41,6 +41,11 @@ /// 轨迹标记id /// public int TrackFlagId { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } } public class GetTrackContentDetailDto @@ -94,5 +99,10 @@ /// 轨迹标记 /// public string TrackFlag { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } } } \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs index 7cf94770..8c0b6b05 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackContents/GetPageTrackContentInput.cs @@ -84,5 +84,10 @@ /// 修改人 /// public string UpdateUser { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } } } \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/EditTrackFlagInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/EditTrackFlagInput.cs index f4c1083e..49bb942a 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/EditTrackFlagInput.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/EditTrackFlagInput.cs @@ -27,10 +27,10 @@ /// public string? Code { get; set; } - /// - /// 是否完结 - /// - public bool IsFinish { get; set; } + ///// + ///// 是否完结 + ///// + //public bool IsFinish { get; set; } } public class GetTrackFlagDetailDto @@ -60,9 +60,9 @@ /// public string Flag { get; set; } - /// - /// 是否完结 - /// - public bool IsFinish { get; set; } + ///// + ///// 是否完结 + ///// + //public bool IsFinish { get; set; } } } \ No newline at end of file diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/GetTrackFlagListDto.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/GetTrackFlagListDto.cs index 4280f8d2..3964caea 100644 --- a/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/GetTrackFlagListDto.cs +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackFlags/GetTrackFlagListDto.cs @@ -22,10 +22,10 @@ /// public string Flag { get; set; } - /// - /// 是否完结 - /// - public bool IsFinish { get; set; } + ///// + ///// 是否完结 + ///// + //public bool IsFinish { get; set; } /// /// 创建时间 diff --git a/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs index bf20809b..77b0c47d 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackContentAutoMapperProfile.cs @@ -9,7 +9,8 @@ namespace SJZY.Track.Application.AutoMapper { public TrackContentAutoMapperProfile() { - CreateMap(MemberList.None); + CreateMap(MemberList.None) + .ForMember(dest => dest.IsCompleted, opt => opt.MapFrom(source => source.IsFinish)); CreateMap(MemberList.None); CreateMap(MemberList.None); CreateMap(MemberList.None); diff --git a/src/SJZY.Track.Application/AutoMapper/TrackFlagAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackFlagAutoMapperProfile.cs index a08aa0a0..bf72f035 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackFlagAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackFlagAutoMapperProfile.cs @@ -10,16 +10,12 @@ namespace SJZY.Track.Application.AutoMapper public TrackFlagAutoMapperProfile() { CreateMap(MemberList.None) - .ForMember(dest => dest.Name, opt => opt.MapFrom(source => source.Flag)) - .ForMember(dest => dest.IsCompleted, opt => opt.MapFrom(source => source.IsFinish)); + .ForMember(dest => dest.Name, opt => opt.MapFrom(source => source.Flag)); + //.ForMember(dest => dest.IsCompleted, opt => opt.MapFrom(source => source.IsFinish)); CreateMap(MemberList.None); CreateMap(MemberList.None); CreateMap, UnifyPageResultDto>(MemberList.None); CreateMap(MemberList.None); - - //var pageResultDto = - // ObjectMapper.Map, UnifyPageResultDto>( - // resultDto); } } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs index 02fac985..44d00b9d 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackContentAggregate/TrackContentEntity.cs @@ -47,4 +47,10 @@ public class TrackContentEntity : IFullAuditedBasicEntitys, IAggregateRoot /// [SugarColumn(ColumnName = "TrackStatusId")] public int TrackStatusId { get; set; } + + /// + /// 是否完结 + /// + [SugarColumn(ColumnName = "IsCompleted")] + public bool IsCompleted { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackFlagAggregate/TrackFlagEntity.cs b/src/SJZY.Track.Domain/Aggregates/TrackFlagAggregate/TrackFlagEntity.cs index 886b458c..225c8f85 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackFlagAggregate/TrackFlagEntity.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackFlagAggregate/TrackFlagEntity.cs @@ -30,9 +30,9 @@ public class TrackFlagEntity : IFullAuditedBasicEntitys, IAggregateRoot [SugarColumn(ColumnName = "SubSystemId")] public int SubSystemId { get; set; } - /// - /// 是否完结 - /// - [SugarColumn(ColumnName = "IsCompleted")] - public bool IsCompleted { get; set; } + ///// + ///// 是否完结 + ///// + //[SugarColumn(ColumnName = "IsCompleted")] + //public bool IsCompleted { get; set; } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs b/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs index d2dc5e29..4fff79ed 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackContents/GetPageTrackContentVO.cs @@ -90,5 +90,10 @@ namespace SJZY.Track.Domain.Dtos.TrackContents /// 修改人 /// public string UpdateUser { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } } } diff --git a/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentDetailVO.cs b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentDetailVO.cs index b58df450..eb5a22b9 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentDetailVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackContents/GetTrackContentDetailVO.cs @@ -57,5 +57,10 @@ namespace SJZY.Track.Domain.Dtos.TrackContents /// 轨迹标记 /// public string TrackFlag { get; set; } + + /// + /// 是否完结 + /// + public bool IsFinish { get; set; } } } diff --git a/src/SJZY.Track.Domain/Dtos/TrackFlags/GetPageTrackFlagVO.cs b/src/SJZY.Track.Domain/Dtos/TrackFlags/GetPageTrackFlagVO.cs index d3699b75..adbf1a5d 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackFlags/GetPageTrackFlagVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackFlags/GetPageTrackFlagVO.cs @@ -46,10 +46,10 @@ namespace SJZY.Track.Domain.Dtos.TrackFlags /// public string Flag { get; set; } - /// - /// 是否完结 - /// - public bool IsFinish { get; set; } + ///// + ///// 是否完结 + ///// + //public bool IsFinish { get; set; } /// /// 创建时间 diff --git a/src/SJZY.Track.Domain/Dtos/TrackFlags/GetTrackFlagDetailVO.cs b/src/SJZY.Track.Domain/Dtos/TrackFlags/GetTrackFlagDetailVO.cs index b88c7afd..d2984d4a 100644 --- a/src/SJZY.Track.Domain/Dtos/TrackFlags/GetTrackFlagDetailVO.cs +++ b/src/SJZY.Track.Domain/Dtos/TrackFlags/GetTrackFlagDetailVO.cs @@ -33,9 +33,9 @@ namespace SJZY.Track.Domain.Dtos.TrackFlags /// public string Flag { get; set; } - /// - /// 是否完结 - /// - public bool IsFinish { get; set; } + ///// + ///// 是否完结 + ///// + //public bool IsFinish { get; set; } } } diff --git a/src/SJZY.Track.Repository/Queries/TrackQueries.cs b/src/SJZY.Track.Repository/Queries/TrackQueries.cs index 814649fe..95e8855f 100644 --- a/src/SJZY.Track.Repository/Queries/TrackQueries.cs +++ b/src/SJZY.Track.Repository/Queries/TrackQueries.cs @@ -74,7 +74,7 @@ public class TrackQueries : ISugarRepository, ITrackQueries, Content = b.Content, EnContent = b.EnContent, Status = c.Status, - IsCompleted = d.IsCompleted + IsCompleted = b.IsCompleted }) .FirstAsync(); } diff --git a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs index 9274e41b..fcd51bd1 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackContentRepository.cs @@ -37,7 +37,8 @@ public class TrackContentRepository : BasicRepository, ITrac Content = a.Content, EnContent = a.EnContent, TrackFlagId = a.TrackFlagId, - TrackFlag = c.Name + TrackFlag = c.Name, + IsFinish = a.IsCompleted }) .FirstAsync(); return detail; @@ -79,7 +80,8 @@ public class TrackContentRepository : BasicRepository, ITrac CreateTime = a.CreateTime, CreateUser = e.Name, UpdateTime = a.UpdateTime, - UpdateUser = f.Name + UpdateUser = f.Name, + IsFinish= a.IsCompleted }) .ToPagedListAsync(input.PageIndex, input.PageSize); diff --git a/src/SJZY.Track.Repository/Repositories/TrackFlagRepository.cs b/src/SJZY.Track.Repository/Repositories/TrackFlagRepository.cs index eb6b8ca1..d2227924 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackFlagRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackFlagRepository.cs @@ -26,8 +26,8 @@ public class TrackFlagRepository : BasicRepository, ITrackFlagR SubSystemId = a.SubSystemId, SubSystem = b.CnName, Code = a.Code, - Flag = a.Name, - IsFinish=a.IsCompleted + Flag = a.Name + //,IsFinish=a.IsCompleted }) .FirstAsync(); return detail; @@ -54,7 +54,7 @@ public class TrackFlagRepository : BasicRepository, ITrackFlagR SubSystem = b.CnName, Code = a.Code, Flag = a.Name, - IsFinish=a.IsCompleted, + //IsFinish=a.IsCompleted, CreateTime = a.CreateTime, CreateUser = c.Name, UpdateTime = a.UpdateTime, From 3298d3cb886a418e170f0f6125080c3e538f1a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=96=87=E7=BF=94?= <878130837@qq.com> Date: Mon, 4 Mar 2024 11:43:29 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/TrackPush/TrackPushCacheService.cs | 7 ++++--- .../Services/TrackPush/TrackPushService.cs | 14 +++++++++----- src/SJZY.Track.Domain/GlobalConst.cs | 5 ----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs index 468d69a8..62df4046 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushCacheService.cs @@ -6,16 +6,17 @@ using Volo.Abp.DependencyInjection; namespace SJZY.Track.Application.Services.TrackPush; -public class TrackPushCacheService:ITrackPushCacheService, ITransientDependency +public class TrackPushCacheService : ITrackPushCacheService, ITransientDependency { private readonly IBasicQuery _trackPushConfigQuery; + private string RedisKey(int customId) => GlobalConst.TrackPushKeyPrefix + customId; public TrackPushCacheService(IBasicQuery trackPushConfigQuery) { _trackPushConfigQuery = trackPushConfigQuery; } - + public async Task IsPushAsync(int customId) { var isPush = @@ -30,7 +31,7 @@ public class TrackPushCacheService:ITrackPushCacheService, ITransientDependency return (bool)isPush; } - + public async Task UpdateAsync(int customId, bool isPush) { await RedisHelper.Client.SetAsync(RedisKey(customId), isPush); diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs index dfdeba35..fa106f23 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -3,6 +3,7 @@ using SJZY.Expand.ABP.Core; using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; using SJZY.Track.Application.Contract.Dtos.TrackPush; +using SJZY.Track.Application.Contract.Services; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; using SJZY.Track.Domain.Aggregates.TrackPushAggregate; @@ -26,17 +27,20 @@ public class TrackPushService : ApplicationService, ITransientDependency private readonly ITrackPushConfigRepository _trackPushConfigRepository; private readonly ITrackTemplateRepository _trackTemplateRepository; private readonly ITrackPullConfigRepository _trackPullConfigRepository; + private readonly ITrackPushCacheService _trackPushCacheService; public TrackPushService( IStringLocalizer stringLocalizer, ITrackPushConfigRepository trackPushConfigRepository, ITrackTemplateRepository trackTemplateRepository, - ITrackPullConfigRepository trackPullConfigRepository) + ITrackPullConfigRepository trackPullConfigRepository, + ITrackPushCacheService trackPushCacheService) { _stringLocalizer = stringLocalizer; _trackPushConfigRepository = trackPushConfigRepository; _trackTemplateRepository = trackTemplateRepository; _trackPullConfigRepository = trackPullConfigRepository; + _trackPushCacheService = trackPushCacheService; } /// @@ -129,7 +133,7 @@ public class TrackPushService : ApplicationService, ITransientDependency trackPushParamsEntity.PullOrPushConfigId = id; await _trackPullConfigRepository.InsertParamsAsync(trackPushParamsEntity); - if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId); + if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId); ts.Complete(); } @@ -154,8 +158,8 @@ public class TrackPushService : ApplicationService, ITransientDependency await _trackPushConfigRepository.UpdateAsync(oldTrackPushEntity); await _trackPullConfigRepository.UpdateParamsAsync(oldTrackPushParamsEntity); - await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldCustomId); - if (input.IsAutoPush) await RedisHelper.Client.SAddAsync(GlobalConst.AutoPushRosterRedisKey, input.CustomId); + await _trackPushCacheService.UpdateAsync(oldCustomId, false); + if (input.IsAutoPush) await _trackPushCacheService.IsPushAsync(input.CustomId); ts.Complete(); } @@ -173,7 +177,7 @@ public class TrackPushService : ApplicationService, ITransientDependency x.PullOrPushConfigId == input.Id && x.IsPush); await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.TrackPushConfigId == input.Id); - await RedisHelper.Client.SRemAsync(GlobalConst.AutoPushRosterRedisKey, oldTrackPushEntity.CustomId); + await _trackPushCacheService.UpdateAsync(oldTrackPushEntity.CustomId, false); ts.Complete(); } diff --git a/src/SJZY.Track.Domain/GlobalConst.cs b/src/SJZY.Track.Domain/GlobalConst.cs index fcf3d893..91cbeca4 100644 --- a/src/SJZY.Track.Domain/GlobalConst.cs +++ b/src/SJZY.Track.Domain/GlobalConst.cs @@ -21,9 +21,4 @@ public class GlobalConst /// 轨迹要推送的客户redis key前缀 /// public const string TrackPushKeyPrefix = "TrackPush:"; - - /// - /// 自动推送名单RedisKey - /// - public const string AutoPushRosterRedisKey = "AutoPushRoster"; } \ No newline at end of file