对外接口包 unifyResultDto
This commit is contained in:
parent
f24168b62d
commit
3a179e7436
@ -10,19 +10,19 @@ public interface IOrderService : IRemoteService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<string> UpsertAsync(UpsertOrderInput input);
|
Task<UnifyResultDto> UpsertAsync(UpsertOrderInput input);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除订单
|
/// 删除订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> DeleteOrderAsync(DeleteOrderInput input);
|
Task<UnifyResultDto> DeleteOrderAsync(DeleteOrderInput input);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联订单
|
/// 关联订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<bool> LinkOrderAsync(LinkOrderInput input);
|
Task<UnifyResultDto> LinkOrderAsync(LinkOrderInput input);
|
||||||
}
|
}
|
||||||
@ -22,13 +22,14 @@ public partial class OrderService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="BusinessException"></exception>
|
/// <exception cref="BusinessException"></exception>
|
||||||
[HttpPost("Order/Link")]
|
[HttpPost("Order/Link")]
|
||||||
public async Task<bool> LinkOrderAsync(LinkOrderInput input)
|
public async Task<UnifyResultDto> LinkOrderAsync(LinkOrderInput input)
|
||||||
{
|
{
|
||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => new
|
||||||
{
|
{
|
||||||
x.Id, x.SubSystemId
|
x.Id,
|
||||||
});
|
x.SubSystemId
|
||||||
|
});
|
||||||
if (order == default)
|
if (order == default)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||||
@ -40,7 +41,7 @@ public partial class OrderService
|
|||||||
throw new BusinessException(message: "不能同级关联");
|
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
|
input.LinkOrderNos = input.LinkOrderNos
|
||||||
@ -64,7 +65,7 @@ public partial class OrderService
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return new UnifyResultDto(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<int>> DoLinkOrderAsync(LinkOrderInput input, int orderId)
|
private async Task<List<int>> DoLinkOrderAsync(LinkOrderInput input, int orderId)
|
||||||
@ -97,7 +98,7 @@ public partial class OrderService
|
|||||||
return canLinkOrders.Select(x => x.Id).ToList();
|
return canLinkOrders.Select(x => x.Id).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> UnLinkOrderAsync(LinkOrderInput input)
|
private async Task<UnifyResultDto> UnLinkOrderAsync(LinkOrderInput input)
|
||||||
{
|
{
|
||||||
var unLinkIds = await _orderLinkQuery.GetListAsync(x =>
|
var unLinkIds = await _orderLinkQuery.GetListAsync(x =>
|
||||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo &&
|
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo &&
|
||||||
@ -107,6 +108,6 @@ public partial class OrderService
|
|||||||
// real del
|
// real del
|
||||||
await _orderRepository.UnLinkByIdsAsync(unLinkIds);
|
await _orderRepository.UnLinkByIdsAsync(unLinkIds);
|
||||||
|
|
||||||
return true;
|
return new UnifyResultDto(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost("Order/Upsert")]
|
[HttpPost("Order/Upsert")]
|
||||||
public async Task<string> UpsertAsync(UpsertOrderInput input)
|
public async Task<UnifyResultDto> UpsertAsync(UpsertOrderInput input)
|
||||||
{
|
{
|
||||||
if (input.Templates.Count == 0) throw new BusinessException(message: "至少有一个模板");
|
if (input.Templates.Count == 0) throw new BusinessException(message: "至少有一个模板");
|
||||||
var order = await _orderRepository.GetFirstAsync(x =>
|
var order = await _orderRepository.GetFirstAsync(x =>
|
||||||
@ -39,7 +39,8 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
{
|
{
|
||||||
// 订单已存在则视为更新
|
// 订单已存在则视为更新
|
||||||
await UpdateOrderAsync(input, order);
|
await UpdateOrderAsync(input, order);
|
||||||
return "更新成功";
|
|
||||||
|
return new UnifyResultDto() { Code = "200", Msg = "操作成功", Data = "创建成功" };
|
||||||
}
|
}
|
||||||
|
|
||||||
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
||||||
@ -48,7 +49,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||||
|
|
||||||
await _orderRepository.CreateOrderAsync(order);
|
await _orderRepository.CreateOrderAsync(order);
|
||||||
return "创建成功";
|
return new UnifyResultDto() { Code = "200", Msg = "操作成功", Data = "新增成功" };
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -58,7 +59,7 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="BusinessException"></exception>
|
/// <exception cref="BusinessException"></exception>
|
||||||
[HttpPost("Order/Delete")]
|
[HttpPost("Order/Delete")]
|
||||||
public async Task<bool> DeleteOrderAsync(DeleteOrderInput input)
|
public async Task<UnifyResultDto> DeleteOrderAsync(DeleteOrderInput input)
|
||||||
{
|
{
|
||||||
var orderId = await _orderRepository.GetFirstAsync(x =>
|
var orderId = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id);
|
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);
|
await _orderRepository.DeleteOrderAsync(orderId);
|
||||||
|
|
||||||
return true;
|
return new UnifyResultDto(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
|
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user