Răsfoiți Sursa

解决同时有系统管理员和部门管理员角色,人员选择问题。

wukai 1 an în urmă
părinte
comite
44b422ea46

+ 9 - 2
doc-admin/src/main/java/com/doc/web/controller/system/SysUserController.java

@@ -31,7 +31,9 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -97,8 +99,13 @@ public class SysUserController extends BaseController {
     @GetMapping("/tree4dept")
     public UserTreeVO tree4dept() {
         SysDept dept = new SysDept();
-        dept.setDeptId(SecurityUtils.getDeptId());
-        List<SysDept> deptList = deptService.selectDeptList(dept);
+        Map<String, Object> params = new HashMap<>(3);
+        String dataScope = StringUtils.format(
+                " AND {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
+                "d", SecurityUtils.getDeptId(), SecurityUtils.getDeptId());
+        params.put("dataScope", dataScope);
+        dept.setParams(params);
+        List<SysDept> deptList = deptService.selectDeptChildrenList(dept);
         List<SysDept> list = deptService.buildDeptTree(deptList);
         SysDept tree = list.get(0);
         return getChildren(tree);

+ 7 - 0
doc-system/src/main/java/com/doc/system/service/ISysDeptService.java

@@ -18,6 +18,13 @@ public interface ISysDeptService {
      * @return 部门信息集合
      */
     public List<SysDept> selectDeptList(SysDept dept);
+    /**
+     * 查询本部门及子部门数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    List<SysDept> selectDeptChildrenList(SysDept dept);
 
     /**
      * 查询所有部门

+ 11 - 0
doc-system/src/main/java/com/doc/system/service/impl/SysDeptServiceImpl.java

@@ -48,6 +48,17 @@ public class SysDeptServiceImpl implements ISysDeptService {
     }
 
     /**
+     * 查询本部门及子部门数据
+     *
+     * @param dept 部门信息
+     * @return 部门信息集合
+     */
+    @Override
+    public List<SysDept> selectDeptChildrenList(SysDept dept) {
+        return deptMapper.selectDeptList(dept);
+    }
+
+    /**
      * 查询所有部门
      *
      * @return