|
|
@@ -1,5 +1,6 @@
|
|
|
package com.izouma.awesomeadmin.service.impl;
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
|
import com.izouma.awesomeadmin.constant.AppConstant;
|
|
|
@@ -27,7 +28,6 @@ import org.apache.log4j.Logger;
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.crypto.SecretKey;
|
|
|
@@ -47,6 +47,8 @@ public class UserInfoServiceImpl implements UserInfoService {
|
|
|
private static Logger logger = Logger.getLogger(UserInfoServiceImpl.class);
|
|
|
private RongCloud rongCloud = RongCloud.getInstance(PropertiesFileLoader.getProperties("rongyunappkey"), PropertiesFileLoader.getProperties("rongyunappsecret"));
|
|
|
|
|
|
+ private WxMaService wxMaService = WeixinConfig.wxMaService();
|
|
|
+
|
|
|
@Autowired
|
|
|
private UserInfoMapper userInfoMapper;
|
|
|
@Autowired
|
|
|
@@ -65,8 +67,6 @@ public class UserInfoServiceImpl implements UserInfoService {
|
|
|
private RecommenderLogMapper recommenderLogMapper;
|
|
|
|
|
|
|
|
|
- private WeixinConfig weixinConfig;
|
|
|
-
|
|
|
@Override
|
|
|
public List<UserInfo> getUserInfoList(UserInfo record) {
|
|
|
|
|
|
@@ -602,7 +602,7 @@ public class UserInfoServiceImpl implements UserInfoService {
|
|
|
@Override
|
|
|
public UserInfo loginMiniApp(String code) {
|
|
|
try {
|
|
|
- WxMaJscode2SessionResult result = weixinConfig.wxMaService().jsCode2SessionInfo(code);
|
|
|
+ WxMaJscode2SessionResult result = wxMaService.jsCode2SessionInfo(code);
|
|
|
String openId = result.getOpenid();
|
|
|
String sessionKey = result.getSessionKey();
|
|
|
|
|
|
@@ -635,12 +635,12 @@ public class UserInfoServiceImpl implements UserInfoService {
|
|
|
public Result getMiniAppUserInfo(String sessionKey, String rawData, String signature,
|
|
|
String encryptedData, String iv) {
|
|
|
// 用户信息校验
|
|
|
- if (!weixinConfig.wxMaService().getUserService().checkUserInfo(sessionKey, rawData, signature)) {
|
|
|
+ if (!wxMaService.getUserService().checkUserInfo(sessionKey, rawData, signature)) {
|
|
|
return new Result(false, "获取用户信息失败");
|
|
|
}
|
|
|
|
|
|
// 解密用户信息
|
|
|
- WxMaUserInfo wxUserInfo = weixinConfig.wxMaService().getUserService().getUserInfo(sessionKey, encryptedData, iv);
|
|
|
+ WxMaUserInfo wxUserInfo = wxMaService.getUserService().getUserInfo(sessionKey, encryptedData, iv);
|
|
|
|
|
|
UserInfo userInfo = new UserInfo();
|
|
|
userInfo.setOpenId(wxUserInfo.getOpenId());
|