轨迹内容编辑

This commit is contained in:
moyongzhen 2024-02-28 14:38:33 +08:00
parent ca2792180a
commit bee28546b4
2 changed files with 103 additions and 3 deletions

View File

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SJZY.Track.Application.Dtos.TrackContents
{
public class EditTrackContentInput
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 操作类型
/// </summary>
public OptionType Options { get; set; }
/// <summary>
/// 子系统id
/// </summary>
public int SubSystemId { get; set; }
/// <summary>
/// 所属轨迹状态id
/// </summary>
public int TrackStatusId { get; set; }
/// <summary>
/// 轨迹内容代码
/// </summary>
public string Code { get; set; }
/// <summary>
/// 轨迹内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 轨迹内容英文
/// </summary>
public string EnContent { get; set; }
/// <summary>
/// 轨迹标记id
/// </summary>
public int TrackFlagId { get; set; }
}
}

View File

@ -1,4 +1,7 @@
using System; using SJZY.Track.Application.Dtos.TrackContents;
using SJZY.Track.Application.Dtos.TrackStatus;
using SJZY.Track.Domain.Aggregates.TrackContentAggregate;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -7,16 +10,62 @@ using Volo.Abp.DependencyInjection;
namespace SJZY.Track.Application.Services.TrackContents namespace SJZY.Track.Application.Services.TrackContents
{ {
/// <summary>
/// 轨迹内容服务
/// </summary>
[ApiExplorerSettings(GroupName = "轨迹内容")] [ApiExplorerSettings(GroupName = "轨迹内容")]
[Route("/Track/Content")] [Route("/Track/Content")]
public class TrackContentService : ApplicationService, ITransientDependency public class TrackContentService : ApplicationService, ITransientDependency
{ {
private readonly ITrackContentRepository _trackContentRepository;
public TrackContentService() public TrackContentService(
ITrackContentRepository trackContentRepository
)
{ {
this._trackContentRepository=trackContentRepository;
} }
/// <summary>
/// 轨迹内容编辑
/// </summary>
/// <returns></returns>
[HttpPost("Edit")]
public async Task<UnifyResultDto> EditAsync(EditTrackContentInput input)
{
return input.Options switch
{
OptionType.新增 => await AddAsync(input),
OptionType.修改 => await UpdateAsync(input),
OptionType.删除 => await DeleteAsync(input),
_ => throw new BusinessException(message: "当前操作动作不合法")
};
}
#region 私有方法
private async Task<UnifyResultDto> AddAsync(EditTrackContentInput input)
{
var entity = ObjectMapper.Map<EditTrackContentInput, TrackContentEntity>(input);
var isTrue = await _trackContentRepository.InsertAsync(entity);
return new UnifyResultDto("200", "新增成功", isTrue);
}
private async Task<UnifyResultDto> UpdateAsync(EditTrackContentInput input)
{
var templateEntity = await _trackContentRepository.GetFirstAsync(a => a.Id == input.Id);
ObjectMapper.Map(input, templateEntity);
var isTrue = await _trackContentRepository.UpdateAsync(templateEntity);
return new UnifyResultDto("200", "修改成功", isTrue);
}
private async Task<UnifyResultDto> DeleteAsync(EditTrackContentInput input)
{
var isTrue = await _trackContentRepository.SoftDeleteAsync(x => x.Id == input.Id);
return new UnifyResultDto("200", "删除成功", isTrue);
}
#endregion
} }
} }