mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 对接lianlian平台
This commit is contained in:
@@ -6,6 +6,7 @@ import com.google.common.collect.Maps;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
import com.jsowell.common.util.JWTUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.thirdparty.CommonParamsDTO;
|
||||
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
|
||||
@@ -51,6 +52,23 @@ public class ThirdPartyBaseController extends BaseController {
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 验证token
|
||||
*/
|
||||
protected boolean verifyToken(String token) {
|
||||
if (StringUtils.equals(token, "jsowellTest")) {
|
||||
// 为了方便测试,token为jsowellTest校验通过
|
||||
return true;
|
||||
}
|
||||
boolean result;
|
||||
try {
|
||||
result = JWTUtils.checkThirdPartyToken(token);
|
||||
} catch (Exception e) {
|
||||
result = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证签名
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.jsowell.web.controller.thirdparty.lianlian;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.jsowell.common.annotation.Anonymous;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
|
||||
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
||||
import com.jsowell.common.exception.BusinessException;
|
||||
@@ -417,17 +418,17 @@ public class LianLianController extends ThirdPartyBaseController {
|
||||
logger.info("联联平台请求启动充电 params :{}", JSON.toJSONString(dto));
|
||||
try {
|
||||
// 校验令牌
|
||||
String token = request.getHeader("Authorization");
|
||||
if (!JWTUtils.checkThirdPartyToken(token)) {
|
||||
boolean verifyToken = verifyToken(request.getHeader("Authorization"));
|
||||
if (!verifyToken) {
|
||||
// 校验失败
|
||||
return CommonResult.failed("令牌校验错误");
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.TOKEN_ERROR);
|
||||
}
|
||||
|
||||
// 校验签名
|
||||
boolean verifySign = verifySign(dto);
|
||||
if (!verifySign) {
|
||||
// 签名错误
|
||||
return CommonResult.failed("签名校验错误");
|
||||
return CommonResult.failed(ThirdPartyReturnCodeEnum.SIGN_ERROR);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
|
||||
@@ -138,11 +138,6 @@ public class JWTUtils {
|
||||
* @return
|
||||
*/
|
||||
public static boolean checkThirdPartyToken(String token) {
|
||||
if (StringUtils.equals(token, "jsowellTest")) {
|
||||
// 为了方便测试,token为jsowellTest校验通过
|
||||
return true;
|
||||
}
|
||||
|
||||
token = getToken(token);
|
||||
if (StringUtils.isBlank(token)) {
|
||||
throw new BusinessException(ReturnCodeEnum.CODE_TOKEN_ERROR);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.jsowell.thirdparty.lianlian.common;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.jsowell.common.enums.thirdparty.ThirdPartyReturnCodeEnum;
|
||||
import com.jsowell.thirdparty.lianlian.common.enums.ResultCode;
|
||||
|
||||
/**
|
||||
@@ -54,8 +55,8 @@ public class CommonResult<T> {
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> CommonResult<T> failed(ResultCode resultCode) {
|
||||
return new CommonResult<T>(resultCode.getCode(), resultCode.getMsg(), null, null);
|
||||
public static <T> CommonResult<T> failed(ThirdPartyReturnCodeEnum resultCode) {
|
||||
return new CommonResult<T>(Long.parseLong(resultCode.getRet()), resultCode.getMsg(), null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user