Merge remote-tracking branch 'origin/cc_20230520_partner' into cc_20230520_partner
This commit is contained in:
@@ -50,13 +50,10 @@ public class WechatRest {
|
|||||||
requestMap.put("secret", secret);
|
requestMap.put("secret", secret);
|
||||||
requestMap.put("js_code", jsCode);
|
requestMap.put("js_code", jsCode);
|
||||||
requestMap.put("grant_type","authorization_code");
|
requestMap.put("grant_type","authorization_code");
|
||||||
ResultDTO responseEntity = null;
|
CodeSessionDTO codeSessionDTO = null;
|
||||||
try {
|
try {
|
||||||
responseEntity = httpRestTemplateService.getForObject(url, ResultDTO.class, requestMap);
|
codeSessionDTO = httpRestTemplateService.getForObject(url, CodeSessionDTO.class, requestMap);
|
||||||
log.info("WechatRest#miniProgramJsCodeSession, url:{}, response:{}", url, JSONObject.toJSONString(responseEntity));
|
log.info("WechatRest#miniProgramJsCodeSession, url:{}, response:{}", url, JSONObject.toJSONString(codeSessionDTO));
|
||||||
if(Objects.nonNull(responseEntity.getData()) && responseEntity.isSuccess()){
|
|
||||||
return JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), CodeSessionDTO.class);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("调用微信服务异常", e);
|
log.error("调用微信服务异常", e);
|
||||||
}
|
}
|
||||||
@@ -70,19 +67,17 @@ public class WechatRest {
|
|||||||
return accessToken;
|
return accessToken;
|
||||||
}
|
}
|
||||||
String reqUrl = String.format(ACCESS_TOKEN, appId, secret);
|
String reqUrl = String.format(ACCESS_TOKEN, appId, secret);
|
||||||
ResultDTO responseEntity = null;
|
JSONObject jsonObject = null;
|
||||||
try {
|
try {
|
||||||
responseEntity = httpRestTemplateService.getForObject(reqUrl, ResultDTO.class, null);
|
jsonObject = httpRestTemplateService.getForObject(reqUrl, JSONObject.class, null);
|
||||||
log.info("WechatRest#getAccessToken, reqUrl:{}, response:{}", reqUrl, JSONObject.toJSONString(responseEntity));
|
log.info("WechatRest#getAccessToken, reqUrl:{}, response:{}", reqUrl, JSONObject.toJSONString(jsonObject));
|
||||||
if(Objects.nonNull(responseEntity.getData()) && responseEntity.isSuccess()){
|
String token = jsonObject.getString("access_token");
|
||||||
JSONObject jsonObject = JSON.parseObject(JSONObject.toJSONString(responseEntity.getData()));
|
if (StringUtils.isBlank(token)) {
|
||||||
String token = jsonObject.getString("access_token");
|
throw new ServiceException(ErrorCodeEnum.GET_ACCESSTOKEN_ERROR);
|
||||||
if (StringUtils.isBlank(token)) {
|
|
||||||
throw new ServiceException(ErrorCodeEnum.GET_ACCESSTOKEN_ERROR);
|
|
||||||
}
|
|
||||||
redisUtilPool.setString(cacheAccessToken, token, 7000);
|
|
||||||
accessToken = token;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redisUtilPool.setString(cacheAccessToken, token, 7000);
|
||||||
|
accessToken = token;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("获取微信小程序token异常", e);
|
log.error("获取微信小程序token异常", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user