同步代码

This commit is contained in:
lulz1 2024-02-29 08:27:06 +08:00
parent aa86243ec0
commit e563cffe37
5 changed files with 37 additions and 13 deletions

View File

@ -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<String> 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")

View File

@ -59,7 +59,7 @@ public class LegEventServiceImpl implements LegEventService {
@Override
@ListenTo(command = "LegFinishedCommand", order = 0)
public void finishLeg(LegFinishedCommand command) {
legEventHandler.finishLeg(command);
}
@Override

View File

@ -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<Long> routeIds;
private String supplierName;
}

View File

@ -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 = "拒绝事件";

View File

@ -17,7 +17,12 @@ 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) {
@ -43,6 +48,7 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
}
return false;
}
private boolean dealWithTokenInfo(String token) {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
var parseJWT = JWTUtil.parseJWT(AuthMessageConstant.SECRET, token);
@ -50,6 +56,7 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
BaseContext.setCurrentUser(withJwt);
return true; // If verification succeeds, continue processing the request
}
private boolean dealWithClientInfo(String token) {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
return true; // If verification succeeds, continue processing the request