mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +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);
|
||||
}
|
||||
|
||||
// 解析入参
|
||||
|
||||
Reference in New Issue
Block a user