Bläddra i källkod

feat:1、叮当-总后台会员列表电话都加密显示、导出明文并设置权限;2、添加看课授权手机号接口;

caoliqin 3 dagar sedan
förälder
incheckning
fb1cefc6d0

+ 3 - 3
fs-admin/src/main/java/com/fs/his/controller/FsUserController.java

@@ -106,7 +106,7 @@ public class FsUserController extends BaseController
         SysRole sysRole = isCheckPermission();
         for (FsUserVO fsUserVO : list) {
             if(fsUserVO.getPhone() != null&&fsUserVO.getPhone()!=""){
-                if (!(sysRole.getIsCheckPhone()==1)){
+                if (!(sysRole.getIsCheckPhone()==1) || CloudHostUtils.hasCloudHostName("叮当国医")){
                     if (fsUserVO.getPhone().length()>11){
                         fsUserVO.setPhone(decryptPhoneMk(fsUserVO.getPhone()));
                     }else {
@@ -203,7 +203,7 @@ public class FsUserController extends BaseController
         SysRole sysRole = isCheckPermission();
         for (FsUserVO fsUserVO : list) {
             if(fsUserVO.getPhone() != null&&fsUserVO.getPhone()!=""){
-                if (!(sysRole.getIsCheckPhone()==1)){
+                if (!(sysRole.getIsCheckPhone()==1) || CloudHostUtils.hasCloudHostName("叮当国医")){
                     if (fsUserVO.getPhone().length()>11){
                         fsUserVO.setPhone(decryptPhoneMk(fsUserVO.getPhone()));
                     }else {
@@ -219,7 +219,7 @@ public class FsUserController extends BaseController
         return getDataTable(list);
     }
 
-    @PreAuthorize("@ss.hasPermi('his:user:export')")
+    @PreAuthorize("@ss.hasPermi('his:user:exportProject')")
     @GetMapping("/exportListProject")
     public AjaxResult exportListProject(FsUser fsUser)
     {

+ 45 - 0
fs-user-app/src/main/java/com/fs/app/controller/UserController.java

@@ -1,16 +1,21 @@
 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 com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.fs.app.annotation.Login;
 import com.fs.app.param.FsDoctorRegisterParam;
 import com.fs.app.param.FsUserEditParam;
+import com.fs.app.param.FsUserPhoneUpdateParam;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.exception.CustomException;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.sign.Md5Utils;
+import com.fs.core.config.WxMaConfiguration;
 import com.fs.course.service.IFsUserCourseVideoService;
 import com.fs.his.domain.FsDoctor;
 import com.fs.his.domain.FsUser;
@@ -35,6 +40,7 @@ import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
+import me.chanjar.weixin.common.error.WxErrorException;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -365,4 +371,43 @@ public class UserController extends  AppBaseController {
     public R removeUser(){
         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("授权失败,请联系管理员");
+    }
 }

+ 35 - 0
fs-user-app/src/main/java/com/fs/app/param/FsUserPhoneUpdateParam.java

@@ -0,0 +1,35 @@
+package com.fs.app.param;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @author caolq
+ * 小程序用户单独授权手机号参数
+ */
+@Data
+public class FsUserPhoneUpdateParam implements Serializable {
+
+    @NotBlank(message = "code不能为空")
+    @ApiModelProperty(value = "小程序登陆code")
+    private String code;
+
+    @ApiModelProperty(value = "小程序完整用户信息的加密数据")
+    private String encryptedData;
+
+    @ApiModelProperty(value = "小程序加密算法的初始向量")
+    private String iv;
+
+    @NotBlank(message = "小程序appid不能为空")
+    @ApiModelProperty(value = "小程序appid")
+    private String appId;
+
+    @NotBlank(message = "userId不能为空")
+    @ApiModelProperty(value = "当前用户id")
+    private String userId;
+
+}