Ver código fonte

部门与部门之间的客户数据隔离

zyy 1 mês atrás
pai
commit
7d53539af7

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

@@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSON;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.domain.ResponseResult;
+import com.fs.common.core.domain.entity.SysDept;
 import com.fs.common.core.domain.entity.SysRole;
 import com.fs.common.core.domain.entity.SysUser;
 import com.fs.common.core.page.PageDomain;
@@ -42,6 +43,7 @@ import com.github.pagehelper.PageInfo;
 import com.google.common.collect.Lists;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.ibatis.session.ExecutorType;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
@@ -152,6 +154,11 @@ public class FsUserController extends BaseController
         if(StringUtils.isNotEmpty(fsUser.getPhone())){
             fsUser.setPhone(encryptPhone(fsUser.getPhone()));
         }
+        SysUser user = getLoginUser().getUser();
+        if (ObjectUtils.isNotEmpty(user) && !user.isAdmin()){
+            SysDept dept = user.getDept();
+            fsUser.setDeptId(dept.getDeptId());
+        }
         //总条数
         CompletableFuture<Integer> totalCompletableFuture = CompletableFuture.supplyAsync(() -> {
             Integer total = fsUserService.selectFsUserVOCountByProject(fsUser);

+ 3 - 0
fs-service/src/main/java/com/fs/his/domain/FsUser.java

@@ -197,6 +197,9 @@ public class FsUser extends BaseEntity
      */
     private Long projectId;
 
+    @TableField(exist = false)
+    private Long deptId;
+
     /**
      * 昵称
      * **/

+ 6 - 0
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -1901,6 +1901,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test = "maps.projectId != null" >
                 AND ucu.project_id = #{maps.projectId}
             </if >
+            <if test="maps.deptId != null">
+                AND company.dept_id = #{maps.deptId}
+            </if>
         </where>
         ORDER BY user_id DESC
         <if test="maps.pageSize != null and maps.pageNum != null">
@@ -1966,6 +1969,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test = "maps.projectId != null" >
                 AND ucu.project_id = #{maps.projectId}
             </if >
+            <if test="maps.deptId != null">
+                AND company.dept_id = #{maps.deptId}
+            </if>
         </where>
     </select>