|
@@ -45,7 +45,6 @@ public class WxUserServiceImpl extends ServiceImpl<IWxUserMapper, WxUser> implem
|
|
|
@Override
|
|
|
public Object wxLogin(String code) {
|
|
|
WxOpenIdVo wxOpenIdVo = wxClient.getOpenIdUrl(WxConfigServiceImpl.wxConfig.getAppId(), WxConfigServiceImpl.wxConfig.getAppSecret(), code);
|
|
|
- log.info("wx-wxLogin-code:{},wxOpenIdVo:{}",code,wxOpenIdVo);
|
|
|
if(wxOpenIdVo.getErrcode() == null && StringUtils.isNotBlank(wxOpenIdVo.getOpenId())){
|
|
|
WxUser wxUser = this.addUser(wxOpenIdVo);
|
|
|
WxUserVo vo = new WxUserVo();
|
|
@@ -99,14 +98,11 @@ public class WxUserServiceImpl extends ServiceImpl<IWxUserMapper, WxUser> implem
|
|
|
@Override
|
|
|
public Object getPhone(String code) {
|
|
|
try {
|
|
|
- log.info("wx-getPhone:code:{}",code);
|
|
|
String token = wxService.getToken();
|
|
|
- log.info("wx-getPhone:token:{},code:{}",token,code);
|
|
|
if(StringUtils.isBlank(token)){
|
|
|
throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
}
|
|
|
JSONObject jsonObject = wxClient.getPhone(token, new WxGetPhoneParam(code));
|
|
|
- log.info("wx-getPhone:token:{},code:{},result:{}",token,code,jsonObject);
|
|
|
JSONObject phoneObj = (JSONObject) jsonObject.get("phone_info");
|
|
|
if(phoneObj==null){
|
|
|
throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
@@ -118,4 +114,19 @@ public class WxUserServiceImpl extends ServiceImpl<IWxUserMapper, WxUser> implem
|
|
|
}
|
|
|
throw new BusinessException(ResultCode.WX_PHONE_ERROR);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Object userInfo(String token) {
|
|
|
+ if(StringUtils.isBlank(token)){
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
+ }
|
|
|
+ String wxUserId = JwtUtil.getUserName(token);
|
|
|
+ if(StringUtils.isBlank(wxUserId)){
|
|
|
+ throw new BusinessException(ResultCode.USER_NOT_LOGIN);
|
|
|
+ }
|
|
|
+ WxUser wxUser = this.getById(wxUserId);
|
|
|
+ WxUserVo vo = new WxUserVo();
|
|
|
+ BeanUtils.copyProperties(wxUser,vo);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|