From e563cffe37c86857993be846361baf1653c0dbcf Mon Sep 17 00:00:00 2001 From: lulz1 Date: Thu, 29 Feb 2024 08:27:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chint/application/in/OrderController.java | 18 ++++++++++++++++-- .../leg_event/LegEventServiceImpl.java | 2 +- .../domain/value_object/SyncLegData.java | 3 +++ .../infrastructure/constant/LegConstant.java | 8 ++++---- .../webconfig/JwtTokenAdminInterceptor.java | 19 +++++++++++++------ 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/chint/application/in/OrderController.java b/src/main/java/com/chint/application/in/OrderController.java index 943b5630..1ba1dec0 100644 --- a/src/main/java/com/chint/application/in/OrderController.java +++ b/src/main/java/com/chint/application/in/OrderController.java @@ -6,7 +6,9 @@ import com.chint.application.queryies.OrderQuery; import com.chint.application.services.OrderApplicationService; import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.service.OrderDetailDomainService; -import com.chint.domain.value_object.*; +import com.chint.domain.value_object.OrderSaveData; +import com.chint.domain.value_object.SyncLegData; +import com.chint.domain.value_object.UpdateLegData; import com.chint.infrastructure.util.Result; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -41,7 +43,6 @@ public class OrderController { } - @Transactional @ApiOperation("同步行程规划单到供应商") @PostMapping("/sync") @@ -50,6 +51,19 @@ public class OrderController { return Result.Success(SUCCESS); } + @Transactional + @ApiOperation("批量同步行程规划单到供应商") + @PostMapping("/sync/batch") + public Result syncOrderBatch(@RequestBody SyncLegData syncLegData) { + syncLegData.getRouteIds().stream().map(routeId -> { + SyncLegData syncLegDataItem = new SyncLegData(); + syncLegDataItem.setRouteId(routeId); + syncLegDataItem.setSupplierName(syncLegData.getSupplierName()); + return syncLegDataItem; + }).toList().forEach(data -> orderApplicationService.sync(data)); + return Result.Success(SUCCESS); + } + @Transactional @ApiOperation("修改规划节点关联的订单") @PostMapping("/leg/update") diff --git a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java index 5f1e4ef0..2bf4328f 100644 --- a/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java +++ b/src/main/java/com/chint/domain/service/leg_event/LegEventServiceImpl.java @@ -59,7 +59,7 @@ public class LegEventServiceImpl implements LegEventService { @Override @ListenTo(command = "LegFinishedCommand", order = 0) public void finishLeg(LegFinishedCommand command) { - + legEventHandler.finishLeg(command); } @Override diff --git a/src/main/java/com/chint/domain/value_object/SyncLegData.java b/src/main/java/com/chint/domain/value_object/SyncLegData.java index 56ae6543..d3664a4a 100644 --- a/src/main/java/com/chint/domain/value_object/SyncLegData.java +++ b/src/main/java/com/chint/domain/value_object/SyncLegData.java @@ -2,8 +2,11 @@ package com.chint.domain.value_object; import lombok.Data; +import java.util.List; + @Data public class SyncLegData { private Long routeId; + private List routeIds; private String supplierName; } diff --git a/src/main/java/com/chint/infrastructure/constant/LegConstant.java b/src/main/java/com/chint/infrastructure/constant/LegConstant.java index 2cb774bd..ca566a0a 100644 --- a/src/main/java/com/chint/infrastructure/constant/LegConstant.java +++ b/src/main/java/com/chint/infrastructure/constant/LegConstant.java @@ -10,9 +10,9 @@ public class LegConstant { public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单"; public static final int LEG_STATUS_ORDERED = 3; public static final String LEG_STATUS_ORDERED_NAME = "已下单"; - public static final int LEG_STATUS_PAYED = 4; + public static final int LEG_STATUS_PAYED = 5; public static final String LEG_STATUS_PAYED_NAME = "已付款"; - public static final int LEG_STATUS_FINISH = 5; + public static final int LEG_STATUS_FINISH = -2; public static final String LEG_STATUS_FINISH_NAME = "已结束"; public static final int LEG_STATUS_REJECT = -1; public static final String LEG_STATUS_REJECT_NAME = "审批未通过"; @@ -56,9 +56,9 @@ public class LegConstant { public static final String LEG_EVENT_NOT_ORDERED_NAME = "同步事件"; public static final int LEG_EVENT_ORDERED = 3; public static final String LEG_EVENT_ORDERED_NAME = "下单事件"; - public static final int LEG_EVENT_PAYED = 4; + public static final int LEG_EVENT_PAYED = 5; public static final String LEG_EVENT_PAYED_NAME = "付款事件"; - public static final int LEG_EVENT_FINISH = 5; + public static final int LEG_EVENT_FINISH = -2; public static final String LEG_EVENT_FINISH_NAME = "结束事件"; public static final int LEG_EVENT_REJECT = -1; public static final String LEG_EVENT_REJECT_NAME = "拒绝事件"; diff --git a/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java b/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java index 05f281ed..3fc6cdb7 100644 --- a/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java +++ b/src/main/java/com/chint/infrastructure/webconfig/JwtTokenAdminInterceptor.java @@ -17,16 +17,21 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { try { - String token = request.getHeader(AuthMessageConstant.HEADER_TOKEN); + String token = null; + token = request.getHeader(AuthMessageConstant.HEADER_TOKEN); + if (token != null) { + return dealWithTokenInfo(token); + } + if (token == null) { token = request.getHeader(AuthMessageConstant.HEADER_TOKEN_UP_CASE); - if (token != null){ + if (token != null) { return dealWithTokenInfo(token); } } - if (token == null){ + if (token == null) { token = request.getHeader(AuthMessageConstant.HEADER_CLIENT_CASE); - if (token != null){ + if (token != null) { return dealWithClientInfo(token); } } @@ -43,14 +48,16 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor { } return false; } - private boolean dealWithTokenInfo(String token){ + + private boolean dealWithTokenInfo(String token) { JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token); var parseJWT = JWTUtil.parseJWT(AuthMessageConstant.SECRET, token); var withJwt = User.withJwt(parseJWT); BaseContext.setCurrentUser(withJwt); return true; // If verification succeeds, continue processing the request } - private boolean dealWithClientInfo(String token){ + + private boolean dealWithClientInfo(String token) { JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token); return true; // If verification succeeds, continue processing the request }