change:订单增删改返回id
This commit is contained in:
parent
85b05dfa5d
commit
7206bc64cd
@ -10,14 +10,14 @@ public interface IOrderService : IRemoteService
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<UnifyResultDto> UpsertAsync(UpsertOrderInput input);
|
Task<UnifyResultDto<IdBaseDto>> UpsertAsync(UpsertOrderInput input);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除订单
|
/// 删除订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<UnifyResultDto> DeleteOrderAsync(DeleteOrderInput input);
|
Task<UnifyResultDto<IdBaseDto>> DeleteOrderAsync(DeleteOrderInput input);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 关联订单
|
/// 关联订单
|
||||||
|
|||||||
@ -32,7 +32,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<UnifyResultDto> UpsertAsync(UpsertOrderInput input)
|
public async Task<UnifyResultDto<IdBaseDto>> UpsertAsync(UpsertOrderInput input)
|
||||||
{
|
{
|
||||||
var subSystemId = CurrentUserRequest.SubSystemId;
|
var subSystemId = CurrentUserRequest.SubSystemId;
|
||||||
|
|
||||||
@ -44,25 +44,21 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
// 订单已存在则视为更新
|
// 订单已存在则视为更新
|
||||||
await UpdateOrderAsync(input, order);
|
await UpdateOrderAsync(input, order);
|
||||||
|
|
||||||
return new UnifyResultDto()
|
return new UnifyResultDto<IdBaseDto>(true, new IdBaseDto
|
||||||
{
|
{
|
||||||
Code = "200",
|
Id = order.Id
|
||||||
Msg = "操作成功",
|
});
|
||||||
Data = "创建成功"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
|
||||||
order.SubSystemId = subSystemId;
|
order.SubSystemId = subSystemId;
|
||||||
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
|
||||||
|
|
||||||
await _orderRepository.CreateOrderAsync(order);
|
var orderId = await _orderRepository.CreateOrderAsync(order);
|
||||||
return new UnifyResultDto()
|
return new UnifyResultDto<IdBaseDto>(true, new IdBaseDto
|
||||||
{
|
{
|
||||||
Code = "200",
|
Id = orderId
|
||||||
Msg = "操作成功",
|
});
|
||||||
Data = "新增成功"
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -72,10 +68,11 @@ 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<UnifyResultDto> DeleteOrderAsync(DeleteOrderInput input)
|
public async Task<UnifyResultDto<IdBaseDto>> DeleteOrderAsync(DeleteOrderInput input)
|
||||||
{
|
{
|
||||||
|
var susSystemId = CurrentUserRequest.SubSystemId;
|
||||||
var orderId = await _orderRepository.GetFirstAsync(x =>
|
var orderId = await _orderRepository.GetFirstAsync(x =>
|
||||||
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id);
|
x.SubSystemId == susSystemId && x.OrderType == input.OrderType && x.OrderNo == input.OrderNo, x => x.Id);
|
||||||
if (orderId == default)
|
if (orderId == default)
|
||||||
{
|
{
|
||||||
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
throw new BusinessException(message: $"订单:{input.OrderNo}不存在");
|
||||||
@ -83,7 +80,10 @@ public partial class OrderService : ApplicationService, IOrderService
|
|||||||
|
|
||||||
await _orderRepository.DeleteOrderAsync(orderId);
|
await _orderRepository.DeleteOrderAsync(orderId);
|
||||||
|
|
||||||
return new UnifyResultDto(true, true);
|
return new UnifyResultDto<IdBaseDto>(true, new IdBaseDto
|
||||||
|
{
|
||||||
|
Id = orderId
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
|
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
|
||||||
|
|||||||
@ -9,7 +9,7 @@ public interface IOrderRepository : IBasicRepository<OrderEntity>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="order"></param>
|
/// <param name="order"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task CreateOrderAsync(OrderEntity order);
|
Task<int> CreateOrderAsync(OrderEntity order);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新订单
|
/// 更新订单
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace SJZY.Track.Repository.Repositories;
|
|||||||
|
|
||||||
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, ITransientDependency
|
||||||
{
|
{
|
||||||
public async Task CreateOrderAsync(OrderEntity order)
|
public async Task<int> CreateOrderAsync(OrderEntity order)
|
||||||
{
|
{
|
||||||
using var tran = TransactionHelper.GetReadCommitted();
|
using var tran = TransactionHelper.GetReadCommitted();
|
||||||
|
|
||||||
@ -15,6 +15,8 @@ public class OrderRepository : BasicRepository<OrderEntity>, IOrderRepository, I
|
|||||||
await Context.Insertable(order.OrderFlights).ExecuteCommandAsync();
|
await Context.Insertable(order.OrderFlights).ExecuteCommandAsync();
|
||||||
|
|
||||||
tran.Complete();
|
tran.Complete();
|
||||||
|
|
||||||
|
return orderId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<int> UpdateBatchIdsAsync(List<int> ids, int newValue)
|
public Task<int> UpdateBatchIdsAsync(List<int> ids, int newValue)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user