处理微信登录问题
This commit is contained in:
parent
47aad30c42
commit
caed4541f4
|
|
@ -24,6 +24,7 @@ public class ChannelMpServiceImpl implements IChannelMpService {
|
|||
@Override
|
||||
public Map<String, Object> detail() {
|
||||
Map<String, String> config = ConfigUtil.get("mp_channel");
|
||||
System.out.println(config);
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("name", config.getOrDefault("name", ""));
|
||||
map.put("primaryId", config.getOrDefault("primaryId", ""));
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
package com.mdd.front.controller;
|
||||
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
import com.mdd.front.LikeFrontThreadLocal;
|
||||
import com.mdd.front.service.IUserService;
|
||||
import com.mdd.front.vo.user.UserCenterVo;
|
||||
import com.mdd.front.vo.user.UserInfoVo;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/user")
|
||||
|
|
@ -61,7 +60,8 @@ public class UserController {
|
|||
* @return Object
|
||||
*/
|
||||
@PostMapping("/mnpMobile")
|
||||
public Object mnpMobile() {
|
||||
public Object mnpMobile(@RequestBody Map<String, String> params) {
|
||||
iUserService.mnpMobile(params);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package com.mdd.front.service;
|
|||
import com.mdd.front.vo.user.UserCenterVo;
|
||||
import com.mdd.front.vo.user.UserInfoVo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户服务接口类
|
||||
*/
|
||||
|
|
@ -26,4 +28,6 @@ public interface IUserService {
|
|||
*/
|
||||
UserInfoVo info(Integer userId);
|
||||
|
||||
void mnpMobile(Map<String, String> params);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,7 +96,8 @@ public class LoginServiceImpl implements ILoginService {
|
|||
try {
|
||||
WxMaJscode2SessionResult sessionResult = wxMaService.getUserService().getSessionInfo(code);
|
||||
String openId = sessionResult.getOpenid();
|
||||
String unionId = sessionResult.getUnionid();
|
||||
String uniId = sessionResult.getUnionid();
|
||||
String unionId = uniId == null ? "" : uniId;
|
||||
|
||||
UserAuth userAuth = userAuthMapper.selectOne(new QueryWrapper<UserAuth>()
|
||||
.eq("client", client)
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
package com.mdd.front.service.impl;
|
||||
|
||||
import cn.binarywang.wx.miniapp.api.WxMaService;
|
||||
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.mdd.common.config.GlobalConfig;
|
||||
import com.mdd.common.entity.system.SystemConfig;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.enums.ClientEnum;
|
||||
import com.mdd.common.mapper.system.SystemConfigMapper;
|
||||
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||
import com.mdd.common.mapper.user.UserMapper;
|
||||
import com.mdd.common.utils.ConfigUtil;
|
||||
|
|
@ -13,10 +19,12 @@ import com.mdd.common.utils.UrlUtil;
|
|||
import com.mdd.front.service.IUserService;
|
||||
import com.mdd.front.vo.user.UserCenterVo;
|
||||
import com.mdd.front.vo.user.UserInfoVo;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户服务实现类
|
||||
|
|
@ -56,6 +64,13 @@ public class UserServiceImpl implements IUserService {
|
|||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人信息
|
||||
*
|
||||
* @author fzr
|
||||
* @param userId 用户ID
|
||||
* @return UserInfoVo
|
||||
*/
|
||||
@Override
|
||||
public UserInfoVo info(Integer userId) {
|
||||
User user = userMapper.selectOne(new QueryWrapper<User>()
|
||||
|
|
@ -87,4 +102,30 @@ public class UserServiceImpl implements IUserService {
|
|||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信手机号
|
||||
*/
|
||||
@Override
|
||||
public void mnpMobile(Map<String, String> params) {
|
||||
Map<String, String> config = ConfigUtil.get("mp_channel");
|
||||
WxMaService wxMaService = new WxMaServiceImpl();
|
||||
WxMaDefaultConfigImpl wxConfig = new WxMaDefaultConfigImpl();
|
||||
wxConfig.setSecret(config.getOrDefault("appSecret", ""));
|
||||
wxConfig.setAppid(config.getOrDefault("appId", ""));
|
||||
wxMaService.setWxMaConfig(wxConfig);
|
||||
|
||||
try {
|
||||
String sessionKey = "";
|
||||
String encryptedData = params.get("encryptedData");
|
||||
String ivStr = params.get("iv");
|
||||
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxMaService.getUserService()
|
||||
.getNewPhoneNoInfo("093bd81w3n9ocZ2KZu2w3XBZ034bd81S");
|
||||
|
||||
|
||||
} catch (WxErrorException e) {
|
||||
System.out.println(e.getError());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue