调整获取微信手机号接口
This commit is contained in:
parent
7cfb55124c
commit
43da5265ff
|
|
@ -113,8 +113,8 @@ public class UserController {
|
||||||
@PostMapping("/mnpMobile")
|
@PostMapping("/mnpMobile")
|
||||||
public Object mnpMobile(@RequestBody Map<String, String> params) {
|
public Object mnpMobile(@RequestBody Map<String, String> params) {
|
||||||
Assert.notNull(params.get("code"), "code参数缺失");
|
Assert.notNull(params.get("code"), "code参数缺失");
|
||||||
Map<String, Object> map = iUserService.mnpMobile(params.get("code").trim());
|
iUserService.mnpMobile(params.get("code").trim());
|
||||||
return AjaxResult.success(map);
|
return AjaxResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,7 @@ public interface IUserService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param code 获取手机号的Code
|
* @param code 获取手机号的Code
|
||||||
* @return Map<String, Object>
|
|
||||||
*/
|
*/
|
||||||
Map<String, Object> mnpMobile(String code);
|
void mnpMobile(String code);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import com.mdd.common.mapper.system.SystemConfigMapper;
|
||||||
import com.mdd.common.mapper.user.UserAuthMapper;
|
import com.mdd.common.mapper.user.UserAuthMapper;
|
||||||
import com.mdd.common.mapper.user.UserMapper;
|
import com.mdd.common.mapper.user.UserMapper;
|
||||||
import com.mdd.common.utils.*;
|
import com.mdd.common.utils.*;
|
||||||
|
import com.mdd.front.LikeFrontThreadLocal;
|
||||||
import com.mdd.front.service.IUserService;
|
import com.mdd.front.service.IUserService;
|
||||||
import com.mdd.front.vo.user.UserCenterVo;
|
import com.mdd.front.vo.user.UserCenterVo;
|
||||||
import com.mdd.front.vo.user.UserInfoVo;
|
import com.mdd.front.vo.user.UserInfoVo;
|
||||||
|
|
@ -243,10 +244,9 @@ public class UserServiceImpl implements IUserService {
|
||||||
*
|
*
|
||||||
* @author fzr
|
* @author fzr
|
||||||
* @param code 获取手机号的Code
|
* @param code 获取手机号的Code
|
||||||
* @return Map<String, Object>
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> mnpMobile(String code) {
|
public void mnpMobile(String code) {
|
||||||
Map<String, String> config = ConfigUtil.get("mp_channel");
|
Map<String, String> config = ConfigUtil.get("mp_channel");
|
||||||
WxMaService wxMaService = new WxMaServiceImpl();
|
WxMaService wxMaService = new WxMaServiceImpl();
|
||||||
WxMaDefaultConfigImpl wxConfig = new WxMaDefaultConfigImpl();
|
WxMaDefaultConfigImpl wxConfig = new WxMaDefaultConfigImpl();
|
||||||
|
|
@ -257,10 +257,12 @@ public class UserServiceImpl implements IUserService {
|
||||||
try {
|
try {
|
||||||
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxMaService.getUserService().getNewPhoneNoInfo(code);
|
WxMaPhoneNumberInfo wxMaPhoneNumberInfo = wxMaService.getUserService().getNewPhoneNoInfo(code);
|
||||||
|
|
||||||
Map<String, Object> response = new LinkedHashMap<>();
|
Integer userId = LikeFrontThreadLocal.getUserId();
|
||||||
response.put("countryCode", wxMaPhoneNumberInfo.getCountryCode());
|
User user = new User();
|
||||||
response.put("phoneNumber", wxMaPhoneNumberInfo.getPhoneNumber());
|
user.setId(userId);
|
||||||
return response;
|
user.setMobile(wxMaPhoneNumberInfo.getPhoneNumber());
|
||||||
|
user.setCreateTime(System.currentTimeMillis() / 1000);
|
||||||
|
userMapper.updateById(user);
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
throw new OperateException(e.getError().getErrorCode() + ", " + e.getError().getErrorMsg());
|
throw new OperateException(e.getError().getErrorCode() + ", " + e.getError().getErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue