|
|
@@ -1,87 +0,0 @@
|
|
|
-//package com.chuanghai.h3c_reporting.util;
|
|
|
-//
|
|
|
-//import com.alibaba.excel.util.StringUtils;
|
|
|
-//import com.alibaba.fastjson.JSON;
|
|
|
-//import com.alibaba.fastjson.JSONObject;
|
|
|
-//import com.chuanghai.h3c_reporting.common.exception.BizCodeEnume;
|
|
|
-//import com.chuanghai.h3c_reporting.common.exception.RRException;
|
|
|
-//import lombok.extern.slf4j.Slf4j;
|
|
|
-//import org.springframework.http.HttpStatus;
|
|
|
-//import org.springframework.http.client.ClientHttpResponse;
|
|
|
-//import org.springframework.stereotype.Component;
|
|
|
-//import org.springframework.web.client.ResponseErrorHandler;
|
|
|
-//import org.springframework.web.client.RestTemplate;
|
|
|
-//
|
|
|
-//import java.io.IOException;
|
|
|
-//import java.util.HashMap;
|
|
|
-//import java.util.Map;
|
|
|
-//
|
|
|
-///**
|
|
|
-// * @Author 浮生
|
|
|
-// * @Date 2023/3/12 14:30
|
|
|
-// * @PackageName:com.chuanghai.h3c_reporting.util
|
|
|
-// * @ClassName: WxUtils
|
|
|
-// * @Description: TODO
|
|
|
-// * @Version 1.0
|
|
|
-// */
|
|
|
-//@Component
|
|
|
-//@Slf4j
|
|
|
-//public class WxUtils {
|
|
|
-// private final RestTemplate restTemplate;
|
|
|
-//
|
|
|
-// {
|
|
|
-// restTemplate = new RestTemplate();
|
|
|
-// ResponseErrorHandler responseErrorHandler = new ResponseErrorHandler() {
|
|
|
-// @Override
|
|
|
-// public boolean hasError(ClientHttpResponse response) throws IOException {
|
|
|
-// return false;
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void handleError(ClientHttpResponse response) throws IOException {
|
|
|
-// HttpStatus statusCode = response.getStatusCode();
|
|
|
-// String statusText = response.getStatusText();
|
|
|
-// log.info("【微信接口请求失败】 errorCode={},errorMsg={}", statusCode, statusText);
|
|
|
-// throw new RRException(BizCodeEnume.WX_EXCEPTION, "微信网络繁忙,请稍后再试。");
|
|
|
-// }
|
|
|
-// };
|
|
|
-//
|
|
|
-// restTemplate.setErrorHandler(responseErrorHandler);
|
|
|
-// }
|
|
|
-//
|
|
|
-//
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * @params: []
|
|
|
-// * @return: java.lang.String
|
|
|
-// * @Description: 获取用户openId
|
|
|
-// */
|
|
|
-// public String code2Session(String appId, String secret, String code) {
|
|
|
-//
|
|
|
-//
|
|
|
-// //组装参数
|
|
|
-// Map<String, String> params = new HashMap<>();
|
|
|
-// params.put("appid", appId);
|
|
|
-// params.put("secret", secret);
|
|
|
-// params.put("code", code);
|
|
|
-// params.put("grant_type", "authorization_code");
|
|
|
-//
|
|
|
-//
|
|
|
-// StringBuilder sb = new StringBuilder(UrlConstants.WX_CODE_2_SESSION);
|
|
|
-// sb.append("?")
|
|
|
-// .append("appid=").append(appId).append("&")
|
|
|
-// .append("secret=").append(secret).append("&")
|
|
|
-// .append("js_code=").append(code).append("&")
|
|
|
-// .append("grant_type=").append("authorization_code");
|
|
|
-//
|
|
|
-// String result = restTemplate.getForObject(sb.toString(), String.class);
|
|
|
-//
|
|
|
-// JSONObject jsonResult = JSON.parseObject(result);
|
|
|
-// String openid = jsonResult.getString("openid");
|
|
|
-// if (StringUtils.isEmpty(openid)) {
|
|
|
-// log.error("【微信code2Session失败!】url={},Params:{},wxResult={}", sb.toString(), JSON.toJSONString(params), result);
|
|
|
-// throw new RRException(BizCodeEnume.WX_EXCEPTION, "获取用户信息失败,请稍后再试。");
|
|
|
-// }
|
|
|
-// return jsonResult.getString("openid");
|
|
|
-// }
|
|
|
-//}
|