增加登录状态校验(未完成)

master
jingling 8 months ago
parent ee81086828
commit 5e02b1d31d

@ -234,6 +234,7 @@ xxl:
# ===================== 微信小程序配置 =====================
wx:
code2Session: https://api.weixin.qq.com/sns/jscode2session
checkSession: https://api.weixin.qq.com/wxa/checksession
# 回收员端
huishouyuan:
appid: wxf82bcc798891a29d

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.model.wx.WxCheckSession;
import jnpf.model.wx.WxLoginParam;
import jnpf.util.wxutil.HttpUtil;
import lombok.extern.slf4j.Slf4j;
@ -30,10 +31,12 @@ public class WxController {
private String appsecret;
@Value("${wx.code2Session}")
private String code2Session;
@Value("${wx.checkSession}")
private String checkSession;
@Operation(summary = "小程序登录-回收员端")
@GetMapping("/hsyLogin")
public String login(@RequestParam("code") String code) {
public String hsyLogin(@RequestParam("code") String code) {
log.info("小程序登录-回收员端:{}",code);
String url = code2Session+"?appid="+appid+"&secret="+appsecret+"&js_code="+code+"&grant_type=authorization_code";
return HttpUtil.sendHttpGet(url);
@ -59,6 +62,17 @@ public class WxController {
return decrypt.toString();
}
@Operation(summary = "小程序登录态校验-回收员端")
@GetMapping("/hsyCheckSession")
public String hsyCheckSession(@RequestBody WxCheckSession wxCheckSession) {
log.info("小程序登录态校验-回收员端:{}",JSONObject.toJSONString(wxCheckSession));
// todo
String url = checkSession+"?access_token="+wxCheckSession.getAccessToken()
+"&signature="+wxCheckSession.getSignature()
+"&openid="+wxCheckSession.getOpenid()
+"&sig_method=hmac_sha256";
return HttpUtil.sendHttpGet(url);
}
/**
* json

@ -0,0 +1,11 @@
package jnpf.model.wx;
import lombok.Data;
@Data
public class WxCheckSession {
private String accessToken;// 接口调用凭证
private String openid; // 用户唯一标识符
private String signature;// 用户登录态签名
private String sigMethod;// 用户登录态签名的哈希方法,目前只支持 hmac_sha256
}
Loading…
Cancel
Save