update 海南平台对接

This commit is contained in:
2024-01-25 16:00:35 +08:00
parent 77777b07ea
commit 6e37a276bf
8 changed files with 87 additions and 34 deletions

View File

@@ -0,0 +1,38 @@
package com.jsowell.common.enums.thirdparty;
/**
* 业务信息交换enum
*/
public enum BusinessInformationExchangeEnum {
NOTIFICATION_STATION_STATUS("notification_stationStatus", "设备状态变化推送"),
NOTIFICATION_CHARGE_ORDER_INFO("notification_charge_order_info", "推送充电订单信息"),
NOTIFICATION_START_CHARGE_RESULT("notification_start_charge_result", "推送启动充电结果"),
NOTIFICATION_EQUIP_CHARGE_STATUS("notification_equip_charge_status", "推送充电状态"),
NOTIFICATION_STOP_CHARGE_RESULT("notification_stop_charge_result", "推送停止充电结果"),
CHECK_CHARGE_ORDERS("check_charge_orders", "推送订单对账结果信息"),
;
private String value;
private String label;
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
BusinessInformationExchangeEnum(String value, String label) {
this.value = value;
this.label = label;
}
}

View File

@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.http.HttpServletRequest;
import javax.xml.bind.DatatypeConverter;
import java.security.Key;
import java.util.Date;
@@ -128,6 +129,11 @@ public class JWTUtils {
return claims.getId();
}
/**
* 校验第三方平台token
* @param token 第三方平台token
* @return
*/
public static boolean checkThirdPartyToken(String token) {
token = getToken(token);
if (StringUtils.isBlank(token)) {
@@ -137,6 +143,15 @@ public class JWTUtils {
return StringUtils.isNotBlank(claims.getId());
}
public static boolean checkThirdPartyToken(HttpServletRequest request) {
if (request == null) {
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
}
// 校验令牌
String token = request.getHeader("Authorization");
return checkThirdPartyToken(token);
}
/**
* 替换Bearer
*