Commit 414a5b59 authored by shiyu's avatar shiyu

获取登录用户手机号

parent 8cb57895
...@@ -210,7 +210,19 @@ public class UserServiceImpl implements UserService { ...@@ -210,7 +210,19 @@ public class UserServiceImpl implements UserService {
result.put("isInvited", true); result.put("isInvited", true);
User user = userDao.queryById(dto.getUserId()); User user = userDao.queryById(dto.getUserId());
logger.info("登录用户的信息:{}", JsonUtils.from(user)); logger.info("登录用户的信息:{}", JsonUtils.from(user));
result.put("phone", user.getMobile()); String phone = user.getMobile();
//如果用户手机号为空,则调用微信接口查询出手机号进行保存
if (org.springframework.util.StringUtils.isEmpty(user.getMobile())) {
logger.info("用户id:{}, 手机号为空,需要进行手机号获取, code:{}, loginCode:{}", dto.getUserId(), dto.getCode(), dto.getLoginCode());
if (dto.getLoginType().equals(LoginTypeEnum.WECHAT.getCode())) {
phone = wxLoginManager.getPhone(dto);
if (StringUtils.equals("phoneFalse", phone)) {
logger.info(">>>>>>>>>>>>>FAILED 获取手机号失败 <<<<<<<<<<<<<");
phone = null;
}
}
}
result.put("phone", phone);
// 缓存用户信息 // 缓存用户信息
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId()); String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
redisUtil.set(userKey, user, 2 * 60 * 60); redisUtil.set(userKey, user, 2 * 60 * 60);
......
...@@ -140,6 +140,7 @@ public class WxLoginManager { ...@@ -140,6 +140,7 @@ public class WxLoginManager {
String res = OkHttpUtil.builder().url(accessTokenUrl) String res = OkHttpUtil.builder().url(accessTokenUrl)
.get().sync(); .get().sync();
String token = JsonUtils.getValueByPath(res, "access_token"); String token = JsonUtils.getValueByPath(res, "access_token");
logger.info("测试环境获取token :{} ", token);
return token; return token;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment