add 校验订单至少有一个模板

This commit is contained in:
李鹏军 2024-03-13 15:41:59 +08:00
parent be086de68f
commit 6a911177f7
6 changed files with 12 additions and 11 deletions

View File

@ -45,10 +45,10 @@ public class UpdateOrderInput : OrderNoInfo
/// <summary>
/// 订单模板(传全量)
/// </summary>
public List<OrderTemplateInfo>? Templates { get; set; } = new();
public List<OrderTemplateInfo> Templates { get; set; } = new();
/// <summary>
/// 订单航班信息
/// </summary>
public List<OrderFlightInfo>? FlightInfos { get; set; } = new();
public List<OrderFlightInfo> FlightInfos { get; set; } = new();
}

View File

@ -17,6 +17,7 @@ public class OrderTemplateInfo
/// 模板id
/// </summary>
[Required]
[Range(1, Int32.MaxValue)]
public int TemplateId { get; set; }
/// <summary>

View File

@ -8,7 +8,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.3"/>
<PackageReference Include="SJZY.InterfaceRelay.Application.Contracts" Version="7.1.4"/>
<PackageReference Include="Volo.Abp.Http.Client" Version="7.0.2" />
<PackageReference Include="Volo.Abp.FluentValidation" Version="7.0.2" />
<PackageReference Include="SJZY.UserCenter.HttpApi" Version="3.0.3-alpha8" />

View File

@ -32,6 +32,7 @@ public partial class OrderService : ApplicationService, IOrderService
[HttpPost("Order/Upsert")]
public async Task<string> UpsertAsync(UpsertOrderInput input)
{
if (input.Templates.Count == 0) throw new BusinessException(message: "至少有一个模板");
var order = await _orderRepository.GetFirstAsync(x =>
x.OrderType == input.OrderType && x.OrderNo == input.OrderNo);
if (order != default)
@ -43,8 +44,8 @@ public partial class OrderService : ApplicationService, IOrderService
order = ObjectMapper.Map<UpsertOrderInput, OrderEntity>(input);
order.SubSystemId = CurrentUserRequest.SubSystemId;
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates!);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos!);
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
await _orderRepository.CreateOrderAsync(order);
return "创建成功";
@ -74,8 +75,8 @@ public partial class OrderService : ApplicationService, IOrderService
private async Task UpdateOrderAsync(UpdateOrderInput input, OrderEntity order)
{
order = ObjectMapper.Map(input, order);
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates!);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos!);
order.OrderTemplates = ObjectMapper.Map<List<OrderTemplateInfo>, List<OrderTemplateEntity>>(input.Templates);
order.OrderFlights = ObjectMapper.Map<List<OrderFlightInfo>, List<OrderFlightEntity>>(input.FlightInfos);
await _orderRepository.UpdateOrderAsync(order);
}
}

View File

@ -49,7 +49,7 @@ public class TrackPushPullService : ApplicationService
x.OrderNo
}).ToList();
// 批量获取轨迹 这里报错了,我先随便给个 写死的主体值
// 批量获取轨迹
await _httpClientProxy.Service.BatchForwardThenPushToQueueAsync(
"A012", group.Key.ServiceProviderCode, data,
GlobalConst.TrackRefreshSubscribe, JsonConvert.SerializeObject(group.Key));

View File

@ -68,9 +68,8 @@ namespace SJZY.Track.Application
//用户中心
context.Services.AddHttpClientProxies(typeof(SjzyUserCenterHttpApiModule).Assembly, "UserCenter", false);
context.Services.AddHttpClient("InterfaceForward").AddHttpMessageHandler<InterfaceForwardHeaderHandler>();
context.Services.AddHttpClientProxy<IInterfaceForwardService>(
remoteServiceConfigurationName: "InterfaceForward",
asDefaultService: false
context.Services.AddHttpClientProxies(typeof(SJZYInterfaceRelayApplicationContractsModule).Assembly,
"InterfaceForward", false
);
//CAP