|
@@ -3,7 +3,6 @@ package com.zhongzheng.framework.web.service;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.zhongzheng.common.core.bo.WxLoginResultBo;
|
|
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
|
|
|
|
|
import com.zhongzheng.common.utils.*;
|
|
import com.zhongzheng.common.utils.*;
|
|
@@ -20,7 +19,6 @@ import org.apache.commons.codec.binary.Base64;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
-import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
@@ -45,23 +43,30 @@ public class WxLoginService
|
|
|
|
|
|
|
|
private String wxAuthParam = "appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
|
|
private String wxAuthParam = "appid=%s&secret=%s&js_code=%s&grant_type=authorization_code";
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
- private RestTemplate restTemplate;
|
|
|
|
|
-
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IUserService iUserService;
|
|
private IUserService iUserService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UserMapper userMapper;
|
|
private UserMapper userMapper;
|
|
|
|
|
|
|
|
- public String login(WxLoginBody loginBody) {
|
|
|
|
|
|
|
+ public ClientLoginUser test_login() {
|
|
|
|
|
+ String unionId = "oQ2yp56PgQ-PfwN4vxTZhR5eTpzk";
|
|
|
|
|
+ User user = iUserService.queryByUnionId(unionId);
|
|
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
|
|
+ loginUser.setUser(user);
|
|
|
|
|
+ wxTokenService.createToken(loginUser);
|
|
|
|
|
+ return loginUser;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public ClientLoginUser login(WxLoginBody loginBody) {
|
|
|
User user = getWxUnionIdUser(loginBody);
|
|
User user = getWxUnionIdUser(loginBody);
|
|
|
if(user==null){
|
|
if(user==null){
|
|
|
throw new CustomException("登录错误");
|
|
throw new CustomException("登录错误");
|
|
|
}
|
|
}
|
|
|
ClientLoginUser loginUser = new ClientLoginUser();
|
|
ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
loginUser.setUser(user);
|
|
loginUser.setUser(user);
|
|
|
- return wxTokenService.createToken(loginUser);
|
|
|
|
|
|
|
+ wxTokenService.createToken(loginUser);
|
|
|
|
|
+ return loginUser;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public String refreshToken(String unionId) {
|
|
public String refreshToken(String unionId) {
|
|
@@ -110,7 +115,6 @@ public class WxLoginService
|
|
|
String session_key = String.valueOf(jsonObject.get("session_key"));
|
|
String session_key = String.valueOf(jsonObject.get("session_key"));
|
|
|
String openId = String.valueOf(jsonObject.get("openid"));
|
|
String openId = String.valueOf(jsonObject.get("openid"));
|
|
|
String unionId = String.valueOf(jsonObject.get("unionid"));
|
|
String unionId = String.valueOf(jsonObject.get("unionid"));
|
|
|
- // WxLoginResultBo wxLoginResult = restTemplate.getForObject(url, WxLoginResultBo.class);
|
|
|
|
|
String phoneNumber = obtainWxPhone(loginBody.getIv(),loginBody.getEncryptedData(),session_key);
|
|
String phoneNumber = obtainWxPhone(loginBody.getIv(),loginBody.getEncryptedData(),session_key);
|
|
|
User user = iUserService.queryByUnionId(unionId);
|
|
User user = iUserService.queryByUnionId(unionId);
|
|
|
if(user==null){
|
|
if(user==null){
|