轨迹状态编辑
This commit is contained in:
parent
31951cd0b1
commit
46a669a7db
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SJZY.Track.Application.Dtos.TrackStatus
|
||||
{
|
||||
public class EditTrackStatusInput
|
||||
{
|
||||
/// <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 NodeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态代码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
public string TrackStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态英文
|
||||
/// </summary>
|
||||
public string EntrackStatus { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackStatus
|
||||
{
|
||||
public interface ITrackStatusService
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,72 @@
|
||||
using System;
|
||||
using SJZY.Track.Application.Dtos.TrackStatus;
|
||||
using SJZY.Track.Application.Dtos.TrackTemplates;
|
||||
using SJZY.Track.Domain.TrackStatusAggregate;
|
||||
using SJZY.Track.Domain.TrackTemplateAggregate;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace SJZY.Track.Application.Services.TrackStatus
|
||||
{
|
||||
public class TrackStatusService
|
||||
/// <summary>
|
||||
/// 轨迹状态
|
||||
/// </summary>
|
||||
[ApiExplorerSettings(GroupName = "轨迹状态")]
|
||||
[Route("/Track/Status")]
|
||||
public class TrackStatusService : ApplicationService, ITransientDependency
|
||||
{
|
||||
private readonly ITrackStatusRepository _trackStatusRepository;
|
||||
|
||||
public TrackStatusService(
|
||||
ITrackStatusRepository trackStatusRepository
|
||||
)
|
||||
{
|
||||
this._trackStatusRepository=trackStatusRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 轨迹状态编辑
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("Edit")]
|
||||
public async Task<UnifyResultDto> EditAsync(EditTrackStatusInput 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(EditTrackStatusInput input)
|
||||
{
|
||||
var entity = ObjectMapper.Map<EditTrackStatusInput, TrackStatusEntity>(input);
|
||||
var isTrue = await _trackStatusRepository.InsertAsync(entity);
|
||||
|
||||
return new UnifyResultDto("200", "新增成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> UpdateAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var templateEntity = await _trackStatusRepository.GetFirstAsync(a => a.Id == input.Id);
|
||||
ObjectMapper.Map(input, templateEntity);
|
||||
var isTrue = await _trackStatusRepository.UpdateAsync(templateEntity);
|
||||
|
||||
return new UnifyResultDto("200", "修改成功", isTrue);
|
||||
}
|
||||
|
||||
private async Task<UnifyResultDto> DeleteAsync(EditTrackStatusInput input)
|
||||
{
|
||||
var isTrue = await _trackStatusRepository.SoftDeleteAsync(x => x.Id == input.Id);
|
||||
|
||||
return new UnifyResultDto("200", "删除成功", isTrue);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user