|
@@ -1,16 +1,21 @@
|
|
|
package com.fs.app.controller;
|
|
package com.fs.app.controller;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
|
|
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
|
|
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fs.app.annotation.Login;
|
|
import com.fs.app.annotation.Login;
|
|
|
import com.fs.app.param.FsDoctorRegisterParam;
|
|
import com.fs.app.param.FsDoctorRegisterParam;
|
|
|
import com.fs.app.param.FsUserEditParam;
|
|
import com.fs.app.param.FsUserEditParam;
|
|
|
|
|
+import com.fs.app.param.FsUserPhoneUpdateParam;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.sign.Md5Utils;
|
|
import com.fs.common.utils.sign.Md5Utils;
|
|
|
|
|
+import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
import com.fs.course.service.IFsUserCourseVideoService;
|
|
|
import com.fs.his.domain.FsDoctor;
|
|
import com.fs.his.domain.FsDoctor;
|
|
|
import com.fs.his.domain.FsUser;
|
|
import com.fs.his.domain.FsUser;
|
|
@@ -35,6 +40,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Param;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -365,4 +371,43 @@ public class UserController extends AppBaseController {
|
|
|
public R removeUser(){
|
|
public R removeUser(){
|
|
|
return userService.removeUser(Long.parseLong(getUserId()));
|
|
return userService.removeUser(Long.parseLong(getUserId()));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+// @Login
|
|
|
|
|
+ @ApiOperation("小程序用户单独授权手机号,然后将手机号更新")
|
|
|
|
|
+ @PostMapping("/ma/authUserPhone")
|
|
|
|
|
+ public R updateUserPhone(@RequestBody @Valid FsUserPhoneUpdateParam param){
|
|
|
|
|
+ log.info("【小程序用户单独授权手机号】:{}",param);
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getCode())) {
|
|
|
|
|
+ return R.error("code不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getAppId())) {
|
|
|
|
|
+ return R.error("appId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
|
|
+ return R.error("appId不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ final WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
|
|
|
|
|
+ try {
|
|
|
|
|
+ WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
|
|
|
|
|
+ log.info(session.getSessionKey());
|
|
|
|
|
+ // 解密
|
|
|
|
|
+ WxMaPhoneNumberInfo phoneNoInfo = wxService.getUserService().getPhoneNoInfo(session.getSessionKey(), param.getEncryptedData(), param.getIv());
|
|
|
|
|
+ String phoneNumber = phoneNoInfo.getPhoneNumber();
|
|
|
|
|
+
|
|
|
|
|
+ // 修改用户
|
|
|
|
|
+ FsUser user = fsUserService.selectFsUserById(Long.parseLong(param.getUserId()));
|
|
|
|
|
+ if(user != null){
|
|
|
|
|
+ user.setPhone(phoneNumber);
|
|
|
|
|
+ if(userService.updateFsUser(user)>0) {
|
|
|
|
|
+ return R.ok("授权更新成功").put("user",user);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return R.error("授权更新失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (WxErrorException e) {
|
|
|
|
|
+ return R.error("授权失败,"+e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.error("授权失败,请联系管理员");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|