From 46a669a7db4a0bd255a38857f2f608bbdde4da33 Mon Sep 17 00:00:00 2001 From: moyongzhen <2534173414@qq.com> Date: Tue, 27 Feb 2024 21:17:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A8=E8=BF=B9=E7=8A=B6=E6=80=81=E7=BC=96?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dtos/TrackStatus/EditTrackStatusInput.cs | 46 ++++++++++++++ .../TrackStatus/ITrackStatusService.cs | 12 ++++ .../TrackStatus/TrackStatusService.cs | 63 ++++++++++++++++++- 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs create mode 100644 src/SJZY.Track.Application/Services/TrackStatus/ITrackStatusService.cs diff --git a/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs b/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs new file mode 100644 index 00000000..a77a4f1c --- /dev/null +++ b/src/SJZY.Track.Application/Dtos/TrackStatus/EditTrackStatusInput.cs @@ -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 + { + /// + /// Id + /// + public int Id { get; set; } + + /// + /// 操作类型 + /// + public OptionType Options { get; set; } + + /// + /// 子系统id + /// + public int SubSystemId { get; set; } + + /// + /// 所属节点id + /// + public int NodeId { get; set; } + + /// + /// 轨迹状态代码 + /// + public string Code { get; set; } + + /// + /// 轨迹状态 + /// + public string TrackStatus { get; set; } + + /// + /// 轨迹状态英文 + /// + public string EntrackStatus { get; set; } + } +} diff --git a/src/SJZY.Track.Application/Services/TrackStatus/ITrackStatusService.cs b/src/SJZY.Track.Application/Services/TrackStatus/ITrackStatusService.cs new file mode 100644 index 00000000..eef632b7 --- /dev/null +++ b/src/SJZY.Track.Application/Services/TrackStatus/ITrackStatusService.cs @@ -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 + { + } +} diff --git a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs index 938837c7..432cabad 100644 --- a/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs +++ b/src/SJZY.Track.Application/Services/TrackStatus/TrackStatusService.cs @@ -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 + /// + /// 轨迹状态 + /// + [ApiExplorerSettings(GroupName = "轨迹状态")] + [Route("/Track/Status")] + public class TrackStatusService : ApplicationService, ITransientDependency { + private readonly ITrackStatusRepository _trackStatusRepository; + public TrackStatusService( + ITrackStatusRepository trackStatusRepository + ) + { + this._trackStatusRepository=trackStatusRepository; + } + + /// + /// 轨迹状态编辑 + /// + /// + [HttpPost("Edit")] + public async Task 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 AddAsync(EditTrackStatusInput input) + { + var entity = ObjectMapper.Map(input); + var isTrue = await _trackStatusRepository.InsertAsync(entity); + + return new UnifyResultDto("200", "新增成功", isTrue); + } + + private async Task 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 DeleteAsync(EditTrackStatusInput input) + { + var isTrue = await _trackStatusRepository.SoftDeleteAsync(x => x.Id == input.Id); + + return new UnifyResultDto("200", "删除成功", isTrue); + } + #endregion } }