fix: 允许未配置ERP令牌时启动LMS

This commit is contained in:
zhouz
2026-08-14 16:30:55 +08:00
parent d5876c5812
commit f95808eb2d
2 changed files with 6 additions and 1 deletions

View File

@@ -67,4 +67,5 @@ public interface ErrorCodeConstants {
ErrorCode DAILY_PLAN_CLAIM_MISMATCH = new ErrorCode(42, "日计划领取信息与进度确认不一致"); ErrorCode DAILY_PLAN_CLAIM_MISMATCH = new ErrorCode(42, "日计划领取信息与进度确认不一致");
ErrorCode DAILY_PLAN_CLAIM_PROGRESS_CONFLICT = new ErrorCode(43, "日计划作业进度已变化,该领取无法确认"); ErrorCode DAILY_PLAN_CLAIM_PROGRESS_CONFLICT = new ErrorCode(43, "日计划作业进度已变化,该领取无法确认");
ErrorCode DAILY_PLAN_CLAIM_CANDIDATE_CHANGED = new ErrorCode(44, "日计划候选状态已变化,请重新获取"); ErrorCode DAILY_PLAN_CLAIM_CANDIDATE_CHANGED = new ErrorCode(44, "日计划候选状态已变化,请重新获取");
ErrorCode DAILY_PLAN_ERP_TOKEN_NOT_CONFIGURED = new ErrorCode(45, "ERP日计划接口令牌未配置");
} }

View File

@@ -22,6 +22,7 @@ import java.security.MessageDigest;
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.DAILY_PLAN_ERP_TOKEN_ERROR; import static cn.code.nl.module.lms.enums.ErrorCodeConstants.DAILY_PLAN_ERP_TOKEN_ERROR;
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.DAILY_PLAN_ERP_TOKEN_NOT_CONFIGURED;
/** ERP 日计划对接接口。 */ /** ERP 日计划对接接口。 */
@Tag(name = "ERP - 日计划") @Tag(name = "ERP - 日计划")
@@ -31,7 +32,7 @@ import static cn.code.nl.module.lms.enums.ErrorCodeConstants.DAILY_PLAN_ERP_TOKE
public class ErpDailyPlanController { public class ErpDailyPlanController {
/** ERP 日计划接口令牌。 */ /** ERP 日计划接口令牌。 */
@Value("${erp.daily-plan.token}") @Value("${erp.daily-plan.token:}")
private String erpDailyPlanToken; private String erpDailyPlanToken;
/** 日计划服务。 */ /** 日计划服务。 */
@@ -45,6 +46,9 @@ public class ErpDailyPlanController {
@Parameter(description = "ERP 接口令牌", required = true) @Parameter(description = "ERP 接口令牌", required = true)
@RequestHeader("X-ERP-Token") @NotBlank(message = "ERP接口令牌不能为空") String token, @RequestHeader("X-ERP-Token") @NotBlank(message = "ERP接口令牌不能为空") String token,
@Valid @RequestBody ErpDailyPlanPushReqVO reqVO) { @Valid @RequestBody ErpDailyPlanPushReqVO reqVO) {
if (erpDailyPlanToken.isBlank()) {
throw exception(DAILY_PLAN_ERP_TOKEN_NOT_CONFIGURED);
}
if (!MessageDigest.isEqual(token.getBytes(StandardCharsets.UTF_8), if (!MessageDigest.isEqual(token.getBytes(StandardCharsets.UTF_8),
erpDailyPlanToken.getBytes(StandardCharsets.UTF_8))) { erpDailyPlanToken.getBytes(StandardCharsets.UTF_8))) {
throw exception(DAILY_PLAN_ERP_TOKEN_ERROR); throw exception(DAILY_PLAN_ERP_TOKEN_ERROR);