支付宝和微信工具类参数从sysParam取出
This commit is contained in:
@@ -10,7 +10,6 @@ import com.czg.system.service.SysParamsService;
|
|||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.dubbo.config.annotation.DubboReference;
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -23,7 +22,7 @@ import java.util.Map;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class WechatAuthUtil {
|
public class WechatAuthUtil {
|
||||||
@DubboReference
|
@DubboReference(check = false)
|
||||||
private SysParamsService sysParamsService;
|
private SysParamsService sysParamsService;
|
||||||
|
|
||||||
// @Value("${wx.appId}")
|
// @Value("${wx.appId}")
|
||||||
@@ -86,7 +85,7 @@ public class WechatAuthUtil {
|
|||||||
return JSONObject.parseObject(resp).getString("openid");
|
return JSONObject.parseObject(resp).getString("openid");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSessionKey(String code, String key) {
|
public JSONObject getSession(String code) {
|
||||||
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
||||||
Map<String, Object> requestUrlParam = new HashMap<>();
|
Map<String, Object> requestUrlParam = new HashMap<>();
|
||||||
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
// https://mp.weixin.qq.com/wxopen/devprofile?action=get_profile&token=164113089&lang=zh_CN
|
||||||
@@ -102,7 +101,12 @@ public class WechatAuthUtil {
|
|||||||
String resp = HttpUtil.post(requestUrl, requestUrlParam);
|
String resp = HttpUtil.post(requestUrl, requestUrlParam);
|
||||||
JSONObject jsonObject = JSON.parseObject(resp);
|
JSONObject jsonObject = JSON.parseObject(resp);
|
||||||
log.info("微信获取openid响应报文:{}", resp);
|
log.info("微信获取openid响应报文:{}", resp);
|
||||||
String info = jsonObject.getString(key);
|
return jsonObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSessionKey(String code, String key) {
|
||||||
|
JSONObject session = getSession(code);
|
||||||
|
String info = session.getString(key);
|
||||||
if (StrUtil.isBlank(info)) {
|
if (StrUtil.isBlank(info)) {
|
||||||
throw new RuntimeException(key + "获取失败");
|
throw new RuntimeException(key + "获取失败");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user