添加测试小程序code

This commit is contained in:
2021-07-08 16:16:39 +08:00
parent 0aa8ae8bdf
commit 1824bdb02a
5 changed files with 75 additions and 1 deletions
@@ -217,6 +217,23 @@ public class UserController {
String username = StringUtils.trimToNull(model.getUsername());
String pass = StringUtils.trimToNull(model.getPass());
String weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id");
if(StringUtils.isBlank(weiXinId) && StringUtils.isNotBlank(model.getCode())){
System.out.println("小程序code:"+model.getCode());
WeChatAuthServiceImpl.WeChatWebToken token = weChatAuthService.getWeChatWebToken(model.getCode(), model.getAppId(), model.getAppSecret());
if(token != null) {
weiXinId = token.getOpenid();
} else {
weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id");
}
if(weiXinId == null) {
weiXinId = CookieUtils.getCookieValue(request,"we_chat_open_id");
}
if(weiXinId != null && !weiXinId.equals("")){
CookieUtils.setCookie("we_chat_open_id", weiXinId, "/", 60 * 60 * 24 *7, response);
}
System.out.println("小程序微信OPEN_ID:" + weiXinId);
}
//测试时可以先去掉
if (StringUtils.isBlank(username) || StringUtils.isBlank(pass) || StringUtils.isBlank(weiXinId)){
resultModel.setMsg(Message.PARAM_NOT_NULL);
@@ -16,6 +16,9 @@ public class UserModel extends BaseModel {
private String pass;
private String code;
private List<String> citys;
private String appId;//²âÊÔ
private String appSecret;//²âÊÔ
public List<String> getCitys() {
return citys;
@@ -80,4 +83,20 @@ public class UserModel extends BaseModel {
public void setCode(String code) {
this.code = code;
}
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getAppSecret() {
return appSecret;
}
public void setAppSecret(String appSecret) {
this.appSecret = appSecret;
}
}
@@ -77,7 +77,8 @@
url : "../user/enterpriseLogin",
data : {
"username" : username,
"pass":pass
"pass":pass,
"code":"${code!''}"
},
success : function(result) {
var re = $.parseJSON(result);