fix: 允许未配置ERP令牌时启动LMS
This commit is contained in:
@@ -22,6 +22,7 @@ import java.security.MessageDigest;
|
||||
|
||||
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_NOT_CONFIGURED;
|
||||
|
||||
/** ERP 日计划对接接口。 */
|
||||
@Tag(name = "ERP - 日计划")
|
||||
@@ -31,7 +32,7 @@ import static cn.code.nl.module.lms.enums.ErrorCodeConstants.DAILY_PLAN_ERP_TOKE
|
||||
public class ErpDailyPlanController {
|
||||
|
||||
/** ERP 日计划接口令牌。 */
|
||||
@Value("${erp.daily-plan.token}")
|
||||
@Value("${erp.daily-plan.token:}")
|
||||
private String erpDailyPlanToken;
|
||||
|
||||
/** 日计划服务。 */
|
||||
@@ -45,6 +46,9 @@ public class ErpDailyPlanController {
|
||||
@Parameter(description = "ERP 接口令牌", required = true)
|
||||
@RequestHeader("X-ERP-Token") @NotBlank(message = "ERP接口令牌不能为空") String token,
|
||||
@Valid @RequestBody ErpDailyPlanPushReqVO reqVO) {
|
||||
if (erpDailyPlanToken.isBlank()) {
|
||||
throw exception(DAILY_PLAN_ERP_TOKEN_NOT_CONFIGURED);
|
||||
}
|
||||
if (!MessageDigest.isEqual(token.getBytes(StandardCharsets.UTF_8),
|
||||
erpDailyPlanToken.getBytes(StandardCharsets.UTF_8))) {
|
||||
throw exception(DAILY_PLAN_ERP_TOKEN_ERROR);
|
||||
|
||||
Reference in New Issue
Block a user