diff --git a/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushContentInput.cs b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushContentInput.cs new file mode 100644 index 00000000..0773f3dc --- /dev/null +++ b/src/SJZY.Track.Application.Contract/Dtos/TrackPush/EditTrackPushContentInput.cs @@ -0,0 +1,61 @@ +namespace SJZY.Track.Application.Contract.Dtos.TrackPush; + +public class EditTrackPushContentInput +{ + /// + /// 扩展字段参数值 + /// + public string ExpandFieldsValue { get; set; } + + public int? Id { get; set; } + + /// + /// 操作类型 + /// + public OptionTypeNoNull Options { get; set; } + + /// + /// 推送单号类型 + /// + public int OrderNoType { get; set; } + + /// + /// 推送轨迹排序 + /// + public int Sort { get; set; } + + /// + /// 轨迹代码参数值 + /// + public string TrackContentCodeValue { get; set; } + + /// + /// 轨迹内容id + /// + public int TrackContentId { get; set; } + + /// + /// 轨迹内容参数值 + /// + public string TrackContentValue { get; set; } + + /// + /// 轨迹内容英文参数值 + /// + public string TrackEnContentValue { get; set; } + + /// + /// 轨迹推送配置id + /// + public int TrackPushConfigId { get; set; } + + /// + /// 轨迹状态参数值 + /// + public string TrackStatusValue { get; set; } + + /// + /// 轨迹时区GMT + /// + public string TrackTimeZone { get; set; } +} \ No newline at end of file diff --git a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs index 351f5321..3a42d0e4 100644 --- a/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs +++ b/src/SJZY.Track.Application/AutoMapper/TrackPushAutoMapperProfile.cs @@ -14,5 +14,6 @@ public class TrackPushAutoMapperProfile : Profile .ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds))); CreateMap(MemberList.None).Ignore(dest => dest.Id) .ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true)); + CreateMap(MemberList.None); } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs index cd4567f6..46d10cce 100644 --- a/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs +++ b/src/SJZY.Track.Application/Services/TrackPush/TrackPushService.cs @@ -1,6 +1,9 @@ -using Microsoft.Extensions.Localization; +using AutoMapper.Internal.Mappers; +using Microsoft.Extensions.Localization; +using Nito.AsyncEx; using SJZY.Expand.ABP.Core.Localization; using SJZY.Expand.ABP.Core.PublicMethords; +using SJZY.Track.Application.Contract.Dtos.TrackPull; using SJZY.Track.Application.Contract.Dtos.TrackPush; using SJZY.Track.Application.Localization; using SJZY.Track.Domain.Aggregates.TrackPullAggregate; @@ -102,7 +105,7 @@ public class TrackPushService : ApplicationService, ITransientDependency if (input.Options != OptionTypeNoNull.删除) { Expression> isAnyExp = x => - x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId && x.ServiceProviderId == input.ServiceProviderId; + x.SubSystemId == input.SubSystemId && x.CustomId == input.CustomId && x.ServiceProviderId == input.ServiceProviderId; if (input.Options == OptionTypeNoNull.修改) isAnyExp.And(x => x.Id != input.Id); var trackTemplateIdExp = Expressionable.Create(); @@ -172,4 +175,55 @@ public class TrackPushService : ApplicationService, ITransientDependency return true; } + + /// + /// 轨迹推送配置内容编辑 + /// + /// + /// + [HttpPost("EditContent")] + public async Task EditContentAsync([FromBody] EditTrackPushContentInput input) + { + if (input.Options != OptionTypeNoNull.删除) + { + Expression> isContentAnyExp = x => + x.TrackPushConfigId == input.TrackPushConfigId && x.TrackContentId == input.TrackContentId; + if (input.Options == OptionTypeNoNull.修改) isContentAnyExp.And(x => x.Id != input.Id); + + if (await _trackPushConfigRepository.IsContentAnyAsync(isContentAnyExp)) + throw new BusinessException(message: _stringLocalizer["IsTrackPushContentAny"]); + } + + switch (input.Options) + { + case OptionTypeNoNull.新增: + { + var trackPushContentEntity = ObjectMapper.Map(input); + + await _trackPushConfigRepository.InsertContentAsync(trackPushContentEntity); + } + break; + + case OptionTypeNoNull.修改: + { + var oldTrackPushContentEntity = await _trackPushConfigRepository.GetContentByIdAsync(input.Id!.Value) ?? throw new BusinessException(message: _stringLocalizer["NotFindData"]); + + ObjectMapper.Map(input, oldTrackPushContentEntity); + + await _trackPushConfigRepository.UpdateContentAsync(oldTrackPushContentEntity); + } + break; + + case OptionTypeNoNull.删除: + await _trackPushConfigRepository.SoftDeleteContentAsync(x => x.Id == input.Id); + + break; + + default: + throw new BusinessException(message: _stringLocalizer[SjzyBasicLocalization.Validation_IsInEnum, + nameof(EditTrackPushContentInput.Options)]); + } + + return true; + } } \ No newline at end of file diff --git a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs index 9c82ef1c..808cc3ac 100644 --- a/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs +++ b/src/SJZY.Track.Domain/Aggregates/TrackPushAggregate/ITrackPushConfigRepository.cs @@ -14,4 +14,12 @@ public interface ITrackPushConfigRepository : IBasicRepository GetContentDetailAsync(int id); Task SoftDeleteContentAsync(Expression> whereExpression); + + Task IsContentAnyAsync(Expression> whereExpression); + + Task InsertContentAsync(TrackPushContentConfigEntity insertObj); + + Task GetContentByIdAsync(int id); + + Task UpdateContentAsync(TrackPushContentConfigEntity updateObj); } \ 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 07cbedc7..9c2cb3d2 100644 --- a/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs +++ b/src/SJZY.Track.Repository/Repositories/TrackPushConfigRepository.cs @@ -91,4 +91,24 @@ public class TrackPushConfigRepository : BasicRepository, .SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true) .ExecuteCommandHasChangeAsync(); } + + public async Task IsContentAnyAsync(Expression> whereExpression) + { + return await Context.Queryable().Where(whereExpression).AnyAsync(); + } + + public async Task InsertContentAsync(TrackPushContentConfigEntity insertObj) + { + return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0; + } + + public async Task GetContentByIdAsync(int id) + { + return await Context.Queryable().InSingleAsync(id); + } + + public async Task UpdateContentAsync(TrackPushContentConfigEntity updateObj) + { + return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync(); + } } \ No newline at end of file