|
|
@@ -1,13 +1,16 @@
|
|
|
package cn.tr.module.smart.wx.controller;
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
|
|
|
import cn.binarywang.wx.miniapp.util.WxMaConfigHolder;
|
|
|
+import cn.tr.core.annotation.TenantIgnore;
|
|
|
import cn.tr.core.exception.ServiceException;
|
|
|
import cn.tr.core.exception.TRExcCode;
|
|
|
import cn.tr.core.pojo.CommonResult;
|
|
|
import cn.tr.core.strategy.LoginUserStrategy;
|
|
|
import cn.tr.module.smart.common.service.IBizWxUserService;
|
|
|
+import cn.tr.module.smart.wx.dto.BizWxAppletGetUserPhoneNumberDTO;
|
|
|
import cn.tr.module.smart.wx.dto.BizWxUserShiftHospitalDTO;
|
|
|
import cn.tr.module.smart.wx.dto.WxAppletEncodeInfoDTO;
|
|
|
import cn.tr.module.smart.wx.controller.vo.BizWxUserBindHospitalVO;
|
|
|
@@ -16,6 +19,9 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import java.util.*;
|
|
|
/**
|
|
|
@@ -33,6 +39,7 @@ public class WxAppletUserController {
|
|
|
private final WxMaService wxMaService;
|
|
|
|
|
|
private final IBizWxUserService wxUserService;
|
|
|
+
|
|
|
/**
|
|
|
* <pre>
|
|
|
* 获取用户信息接口
|
|
|
@@ -81,4 +88,23 @@ public class WxAppletUserController {
|
|
|
return CommonResult.success(Boolean.TRUE);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/getUserPhoneNumber")
|
|
|
+ @ApiOperation(value = "快速手机号验证",position = 6)
|
|
|
+ public CommonResult<String> getUserPhoneNumber(@RequestBody@Validated BizWxAppletGetUserPhoneNumberDTO source) throws WxErrorException {
|
|
|
+ log.info("\n手机号快速验证:appid = [{}], accessToken = [{}]",
|
|
|
+ source.getAppid(), source.getAccessToken());
|
|
|
+ if (StringUtils.isAnyBlank(source.getAppid(), source.getAccessToken())) {
|
|
|
+ throw new IllegalArgumentException("请求参数非法,请核实!");
|
|
|
+ }
|
|
|
+ if (!wxMaService.switchover(source.getAppid())) {
|
|
|
+ throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", source.getAppid()));
|
|
|
+ }
|
|
|
+ WxMaPhoneNumberInfo phoneNumber = wxMaService.getUserService().getPhoneNumber(source.getAccessToken());
|
|
|
+ //更新当前用户的手机号
|
|
|
+ wxUserService.updatePhoneById(LoginUserStrategy.tr.getCurrentUserId(),phoneNumber);
|
|
|
+ return CommonResult.success(phoneNumber.getPhoneNumber());
|
|
|
+ }
|
|
|
+
|
|
|
}
|