From 9d29759cc03eb05bbeaf449f83cc14b7c57c4373 Mon Sep 17 00:00:00 2001 From: moyongzhen <2534173414@qq.com> Date: Fri, 29 Mar 2024 14:14:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=B9=E5=A4=96=E6=8E=A5=E5=8F=A3=E5=8C=85?= =?UTF-8?q?=20=20unifyResultDto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/IOrderService.cs | 6 +++--- .../ProvideServices/OrderService.Link.cs | 17 +++++++++-------- .../Services/ProvideServices/OrderService.cs | 11 ++++++----- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs index 0dd34413..adff3b24 100644 --- a/src/SJZY.Track.Application.Contract/Services/IOrderService.cs +++ b/src/SJZY.Track.Application.Contract/Services/IOrderService.cs @@ -10,19 +10,19 @@ public interface IOrderService : IRemoteService /// /// /// - Task UpsertAsync(UpsertOrderInput input); + Task UpsertAsync(UpsertOrderInput input); /// /// 删除订单 /// /// /// - Task DeleteOrderAsync(DeleteOrderInput input); + Task DeleteOrderAsync(DeleteOrderInput input); /// /// 关联订单 /// /// /// - Task LinkOrderAsync(LinkOrderInput input); + Task LinkOrderAsync(LinkOrderInput input); } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs index 88eb9530..7226ee0f 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.Link.cs @@ -22,13 +22,14 @@ public partial class OrderService /// /// [HttpPost("Order/Link")] - public async Task LinkOrderAsync(LinkOrderInput input) + public async Task LinkOrderAsync(LinkOrderInput input) { var order = await _orderRepository.GetFirstAsync(x => x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new - { - x.Id, x.SubSystemId - }); + { + x.Id, + x.SubSystemId + }); if (order == default) { throw new BusinessException(message: $"订单:{input.OrderNo}不存在"); @@ -40,7 +41,7 @@ public partial class OrderService throw new BusinessException(message: "不能同级关联"); } - if (input.LinkOrderNos.Count < 1 || input.LinkOrderType == 0) return true; + if (input.LinkOrderNos.Count < 1 || input.LinkOrderType == 0) return new UnifyResultDto(true); // 单号去重,去空,去自己 input.LinkOrderNos = input.LinkOrderNos @@ -64,7 +65,7 @@ public partial class OrderService }); } - return true; + return new UnifyResultDto(true); } private async Task> DoLinkOrderAsync(LinkOrderInput input, int orderId) @@ -97,7 +98,7 @@ public partial class OrderService return canLinkOrders.Select(x => x.Id).ToList(); } - private async Task UnLinkOrderAsync(LinkOrderInput input) + private async Task UnLinkOrderAsync(LinkOrderInput input) { var unLinkIds = await _orderLinkQuery.GetListAsync(x => x.OrderType == input.OrderType && x.OrderNo == input.OrderNo && @@ -107,6 +108,6 @@ public partial class OrderService // real del await _orderRepository.UnLinkByIdsAsync(unLinkIds); - return true; + return new UnifyResultDto(true); } } \ No newline at end of file diff --git a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs index 712b775c..d562ef9b 100644 --- a/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs +++ b/src/SJZY.Track.Application/Services/ProvideServices/OrderService.cs @@ -30,7 +30,7 @@ public partial class OrderService : ApplicationService, IOrderService /// /// [HttpPost("Order/Upsert")] - public async Task UpsertAsync(UpsertOrderInput input) + public async Task UpsertAsync(UpsertOrderInput input) { if (input.Templates.Count == 0) throw new BusinessException(message: "至少有一个模板"); var order = await _orderRepository.GetFirstAsync(x => @@ -39,7 +39,8 @@ public partial class OrderService : ApplicationService, IOrderService { // 订单已存在则视为更新 await UpdateOrderAsync(input, order); - return "更新成功"; + + return new UnifyResultDto() { Code = "200", Msg = "操作成功", Data = "创建成功" }; } order = ObjectMapper.Map(input); @@ -48,7 +49,7 @@ public partial class OrderService : ApplicationService, IOrderService order.OrderFlights = ObjectMapper.Map, List>(input.FlightInfos); await _orderRepository.CreateOrderAsync(order); - return "创建成功"; + return new UnifyResultDto() { Code = "200", Msg = "操作成功", Data = "新增成功" }; } /// @@ -58,7 +59,7 @@ public partial class OrderService : ApplicationService, IOrderService /// /// [HttpPost("Order/Delete")] - public async Task DeleteOrderAsync(DeleteOrderInput input) + public async Task DeleteOrderAsync(DeleteOrderInput input) { var orderId = await _orderRepository.GetFirstAsync(x => x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id); @@ -69,7 +70,7 @@ public partial class OrderService : ApplicationService, IOrderService await _orderRepository.DeleteOrderAsync(orderId); - return true; + return new UnifyResultDto(true); } private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)