完成 轨迹推送配置内容编辑 接口
This commit is contained in:
parent
3505a4dbcc
commit
a8b0892ab6
@ -0,0 +1,61 @@
|
|||||||
|
namespace SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||||
|
|
||||||
|
public class EditTrackPushContentInput
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 扩展字段参数值
|
||||||
|
/// </summary>
|
||||||
|
public string ExpandFieldsValue { get; set; }
|
||||||
|
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作类型
|
||||||
|
/// </summary>
|
||||||
|
public OptionTypeNoNull Options { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送单号类型
|
||||||
|
/// </summary>
|
||||||
|
public int OrderNoType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 推送轨迹排序
|
||||||
|
/// </summary>
|
||||||
|
public int Sort { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹代码参数值
|
||||||
|
/// </summary>
|
||||||
|
public string TrackContentCodeValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackContentId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容参数值
|
||||||
|
/// </summary>
|
||||||
|
public string TrackContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹内容英文参数值
|
||||||
|
/// </summary>
|
||||||
|
public string TrackEnContentValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送配置id
|
||||||
|
/// </summary>
|
||||||
|
public int TrackPushConfigId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹状态参数值
|
||||||
|
/// </summary>
|
||||||
|
public string TrackStatusValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹时区GMT
|
||||||
|
/// </summary>
|
||||||
|
public string TrackTimeZone { get; set; }
|
||||||
|
}
|
||||||
@ -14,5 +14,6 @@ public class TrackPushAutoMapperProfile : Profile
|
|||||||
.ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds)));
|
.ForMember(dest => dest.TrackTemplateId, opt => opt.MapFrom(source => string.Join(',', source.TrackTemplateIds)));
|
||||||
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
|
CreateMap<EditTrackPushConfigInput, TrackPushPullParamsConfigEntity>(MemberList.None).Ignore(dest => dest.Id)
|
||||||
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
|
.ForMember(dest => dest.IsPush, opt => opt.MapFrom(source => true));
|
||||||
|
CreateMap<EditTrackPushContentInput, TrackPushContentConfigEntity>(MemberList.None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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.Localization;
|
||||||
using SJZY.Expand.ABP.Core.PublicMethords;
|
using SJZY.Expand.ABP.Core.PublicMethords;
|
||||||
|
using SJZY.Track.Application.Contract.Dtos.TrackPull;
|
||||||
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
using SJZY.Track.Application.Contract.Dtos.TrackPush;
|
||||||
using SJZY.Track.Application.Localization;
|
using SJZY.Track.Application.Localization;
|
||||||
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
using SJZY.Track.Domain.Aggregates.TrackPullAggregate;
|
||||||
@ -172,4 +175,55 @@ public class TrackPushService : ApplicationService, ITransientDependency
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轨迹推送配置内容编辑
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost("EditContent")]
|
||||||
|
public async Task<bool> EditContentAsync([FromBody] EditTrackPushContentInput input)
|
||||||
|
{
|
||||||
|
if (input.Options != OptionTypeNoNull.删除)
|
||||||
|
{
|
||||||
|
Expression<Func<TrackPushContentConfigEntity, bool>> 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<EditTrackPushContentInput, TrackPushContentConfigEntity>(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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -14,4 +14,12 @@ public interface ITrackPushConfigRepository : IBasicRepository<TrackPushConfigEn
|
|||||||
Task<GetTrackPushContentDetailOutputVO> GetContentDetailAsync(int id);
|
Task<GetTrackPushContentDetailOutputVO> GetContentDetailAsync(int id);
|
||||||
|
|
||||||
Task<bool> SoftDeleteContentAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression);
|
Task<bool> SoftDeleteContentAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression);
|
||||||
|
|
||||||
|
Task<bool> IsContentAnyAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression);
|
||||||
|
|
||||||
|
Task<bool> InsertContentAsync(TrackPushContentConfigEntity insertObj);
|
||||||
|
|
||||||
|
Task<TrackPushContentConfigEntity> GetContentByIdAsync(int id);
|
||||||
|
|
||||||
|
Task<bool> UpdateContentAsync(TrackPushContentConfigEntity updateObj);
|
||||||
}
|
}
|
||||||
@ -91,4 +91,24 @@ public class TrackPushConfigRepository : BasicRepository<TrackPushConfigEntity>,
|
|||||||
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
.SetColumns(nameof(ISoftDeleteBasicEntity.IsDeleted), true)
|
||||||
.ExecuteCommandHasChangeAsync();
|
.ExecuteCommandHasChangeAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<bool> IsContentAnyAsync(Expression<Func<TrackPushContentConfigEntity, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return await Context.Queryable<TrackPushContentConfigEntity>().Where(whereExpression).AnyAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> InsertContentAsync(TrackPushContentConfigEntity insertObj)
|
||||||
|
{
|
||||||
|
return await Context.Insertable(insertObj).ExecuteCommandAsync() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<TrackPushContentConfigEntity> GetContentByIdAsync(int id)
|
||||||
|
{
|
||||||
|
return await Context.Queryable<TrackPushContentConfigEntity>().InSingleAsync(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> UpdateContentAsync(TrackPushContentConfigEntity updateObj)
|
||||||
|
{
|
||||||
|
return await Context.Updateable(updateObj).ExecuteCommandHasChangeAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user