chenshudong месяцев назад: 4
Родитель
Сommit
29f8bab392

+ 8 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/system/SysDeptController.java

@@ -151,4 +151,12 @@ public class SysDeptController extends BaseController {
151
     public AjaxResult deptLeader(@PathVariable Long deptId) {
151
     public AjaxResult deptLeader(@PathVariable Long deptId) {
152
         return success(deptService.deptLeader(deptId));
152
         return success(deptService.deptLeader(deptId));
153
     }
153
     }
154
+
155
+    /**
156
+     * 查询部门指定角色人员
157
+     */
158
+    @PostMapping(value = "/deptRole/{deptId}")
159
+    public AjaxResult deptRole(@PathVariable Long deptId, @RequestBody List<String> roleKeyList) {
160
+        return success(deptService.deptRole(deptId, roleKeyList));
161
+    }
154
 }
162
 }

+ 2 - 0
airport-common/src/main/java/com/sundot/airport/common/enums/DeptTypeEnum.java

@@ -11,6 +11,8 @@ import lombok.Getter;
11
 public enum DeptTypeEnum {
11
 public enum DeptTypeEnum {
12
 
12
 
13
     STATION("STATION", "机构站"),
13
     STATION("STATION", "机构站"),
14
+    BRIGADE("BRIGADE", "大队"),
15
+    MANAGER("MANAGER", "主管"),
14
     DEPARTMENT("DEPARTMENT", "科室"),
16
     DEPARTMENT("DEPARTMENT", "科室"),
15
     TEAMS("TEAMS", "班组");
17
     TEAMS("TEAMS", "班组");
16
 
18
 

+ 8 - 0
airport-system/src/main/java/com/sundot/airport/system/mapper/SysDeptMapper.java

@@ -148,4 +148,12 @@ public interface SysDeptMapper {
148
      * @return 部门信息
148
      * @return 部门信息
149
      */
149
      */
150
     public List<SysDept> selectDeptByIdList(List<Long> list);
150
     public List<SysDept> selectDeptByIdList(List<Long> list);
151
+
152
+    /**
153
+     * 查询部门指定角色人员
154
+     *
155
+     * @param deptId 部门ID
156
+     * @return 指定角色人员
157
+     */
158
+    public List<SysUser> deptRole(@Param("deptId") Long deptId, @Param("list") List<String> list);
151
 }
159
 }

+ 24 - 16
airport-system/src/main/java/com/sundot/airport/system/service/ISysDeptService.java

@@ -1,6 +1,7 @@
1
 package com.sundot.airport.system.service;
1
 package com.sundot.airport.system.service;
2
 
2
 
3
 import java.util.List;
3
 import java.util.List;
4
+
4
 import com.sundot.airport.common.core.domain.TreeSelect;
5
 import com.sundot.airport.common.core.domain.TreeSelect;
5
 import com.sundot.airport.common.core.domain.DeptUserTreeSelect;
6
 import com.sundot.airport.common.core.domain.DeptUserTreeSelect;
6
 import com.sundot.airport.common.core.domain.entity.SysDept;
7
 import com.sundot.airport.common.core.domain.entity.SysDept;
@@ -11,11 +12,10 @@ import com.sundot.airport.common.core.domain.entity.SysUser;
11
  *
12
  *
12
  * @author ruoyi
13
  * @author ruoyi
13
  */
14
  */
14
-public interface ISysDeptService
15
-{
15
+public interface ISysDeptService {
16
     /**
16
     /**
17
      * 查询部门管理数据
17
      * 查询部门管理数据
18
-     * 
18
+     *
19
      * @param dept 部门信息
19
      * @param dept 部门信息
20
      * @return 部门信息集合
20
      * @return 部门信息集合
21
      */
21
      */
@@ -23,7 +23,7 @@ public interface ISysDeptService
23
 
23
 
24
     /**
24
     /**
25
      * 查询部门树结构信息
25
      * 查询部门树结构信息
26
-     * 
26
+     *
27
      * @param dept 部门信息
27
      * @param dept 部门信息
28
      * @return 部门树信息集合
28
      * @return 部门树信息集合
29
      */
29
      */
@@ -39,7 +39,7 @@ public interface ISysDeptService
39
 
39
 
40
     /**
40
     /**
41
      * 根据角色ID查询部门树信息
41
      * 根据角色ID查询部门树信息
42
-     * 
42
+     *
43
      * @param roleId 角色ID
43
      * @param roleId 角色ID
44
      * @return 选中部门列表
44
      * @return 选中部门列表
45
      */
45
      */
@@ -47,7 +47,7 @@ public interface ISysDeptService
47
 
47
 
48
     /**
48
     /**
49
      * 根据部门ID查询信息
49
      * 根据部门ID查询信息
50
-     * 
50
+     *
51
      * @param deptId 部门ID
51
      * @param deptId 部门ID
52
      * @return 部门信息
52
      * @return 部门信息
53
      */
53
      */
@@ -55,7 +55,7 @@ public interface ISysDeptService
55
 
55
 
56
     /**
56
     /**
57
      * 根据ID查询所有子部门(正常状态)
57
      * 根据ID查询所有子部门(正常状态)
58
-     * 
58
+     *
59
      * @param deptId 部门ID
59
      * @param deptId 部门ID
60
      * @return 子部门数
60
      * @return 子部门数
61
      */
61
      */
@@ -63,7 +63,7 @@ public interface ISysDeptService
63
 
63
 
64
     /**
64
     /**
65
      * 是否存在子节点
65
      * 是否存在子节点
66
-     * 
66
+     *
67
      * @param deptId 部门ID
67
      * @param deptId 部门ID
68
      * @return 结果
68
      * @return 结果
69
      */
69
      */
@@ -71,7 +71,7 @@ public interface ISysDeptService
71
 
71
 
72
     /**
72
     /**
73
      * 查询部门是否存在用户
73
      * 查询部门是否存在用户
74
-     * 
74
+     *
75
      * @param deptId 部门ID
75
      * @param deptId 部门ID
76
      * @return 结果 true 存在 false 不存在
76
      * @return 结果 true 存在 false 不存在
77
      */
77
      */
@@ -79,7 +79,7 @@ public interface ISysDeptService
79
 
79
 
80
     /**
80
     /**
81
      * 校验部门名称是否唯一
81
      * 校验部门名称是否唯一
82
-     * 
82
+     *
83
      * @param dept 部门信息
83
      * @param dept 部门信息
84
      * @return 结果
84
      * @return 结果
85
      */
85
      */
@@ -87,14 +87,14 @@ public interface ISysDeptService
87
 
87
 
88
     /**
88
     /**
89
      * 校验部门是否有数据权限
89
      * 校验部门是否有数据权限
90
-     * 
90
+     *
91
      * @param deptId 部门id
91
      * @param deptId 部门id
92
      */
92
      */
93
     public void checkDeptDataScope(Long deptId);
93
     public void checkDeptDataScope(Long deptId);
94
 
94
 
95
     /**
95
     /**
96
      * 新增保存部门信息
96
      * 新增保存部门信息
97
-     * 
97
+     *
98
      * @param dept 部门信息
98
      * @param dept 部门信息
99
      * @return 结果
99
      * @return 结果
100
      */
100
      */
@@ -102,7 +102,7 @@ public interface ISysDeptService
102
 
102
 
103
     /**
103
     /**
104
      * 修改保存部门信息
104
      * 修改保存部门信息
105
-     * 
105
+     *
106
      * @param dept 部门信息
106
      * @param dept 部门信息
107
      * @return 结果
107
      * @return 结果
108
      */
108
      */
@@ -110,7 +110,7 @@ public interface ISysDeptService
110
 
110
 
111
     /**
111
     /**
112
      * 删除部门管理信息
112
      * 删除部门管理信息
113
-     * 
113
+     *
114
      * @param deptId 部门ID
114
      * @param deptId 部门ID
115
      * @return 结果
115
      * @return 结果
116
      */
116
      */
@@ -158,7 +158,7 @@ public interface ISysDeptService
158
 
158
 
159
     /**
159
     /**
160
      * 构建前端所需要树结构
160
      * 构建前端所需要树结构
161
-     * 
161
+     *
162
      * @param depts 部门列表
162
      * @param depts 部门列表
163
      * @return 树结构列表
163
      * @return 树结构列表
164
      */
164
      */
@@ -166,9 +166,17 @@ public interface ISysDeptService
166
 
166
 
167
     /**
167
     /**
168
      * 构建前端所需要下拉树结构
168
      * 构建前端所需要下拉树结构
169
-     * 
169
+     *
170
      * @param depts 部门列表
170
      * @param depts 部门列表
171
      * @return 下拉树结构列表
171
      * @return 下拉树结构列表
172
      */
172
      */
173
     public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
173
     public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts);
174
+
175
+    /**
176
+     * 查询部门指定角色人员
177
+     *
178
+     * @param deptId 部门ID
179
+     * @return 指定角色人员
180
+     */
181
+    public List<SysUser> deptRole(Long deptId, List<String> roleKeyList);
174
 }
182
 }

+ 25 - 7
airport-system/src/main/java/com/sundot/airport/system/service/impl/SysDeptServiceImpl.java

@@ -117,7 +117,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
117
     /**
117
     /**
118
      * 查找部门及其所有子部门
118
      * 查找部门及其所有子部门
119
      *
119
      *
120
-     * @param depts 部门树
120
+     * @param depts  部门树
121
      * @param deptId 部门ID
121
      * @param deptId 部门ID
122
      * @return 包含指定部门及其所有子部门的树
122
      * @return 包含指定部门及其所有子部门的树
123
      */
123
      */
@@ -222,16 +222,16 @@ public class SysDeptServiceImpl implements ISysDeptService {
222
      */
222
      */
223
     private DeptUserTreeSelect convertDeptToDeptUserTreeSelect(SysDept dept) {
223
     private DeptUserTreeSelect convertDeptToDeptUserTreeSelect(SysDept dept) {
224
         DeptUserTreeSelect treeSelect = new DeptUserTreeSelect(dept);
224
         DeptUserTreeSelect treeSelect = new DeptUserTreeSelect(dept);
225
-        
225
+
226
         List<DeptUserTreeSelect> children = new ArrayList<>();
226
         List<DeptUserTreeSelect> children = new ArrayList<>();
227
-        
227
+
228
         // 处理子部门
228
         // 处理子部门
229
         if (dept.getChildren() != null && !dept.getChildren().isEmpty()) {
229
         if (dept.getChildren() != null && !dept.getChildren().isEmpty()) {
230
             children.addAll(dept.getChildren().stream()
230
             children.addAll(dept.getChildren().stream()
231
                     .map(this::convertDeptToDeptUserTreeSelect)
231
                     .map(this::convertDeptToDeptUserTreeSelect)
232
                     .collect(Collectors.toList()));
232
                     .collect(Collectors.toList()));
233
         }
233
         }
234
-        
234
+
235
         // 如果是班组类型,则添加用户节点
235
         // 如果是班组类型,则添加用户节点
236
         if (DeptTypeEnum.TEAMS.getCode().equals(dept.getDeptType())) {
236
         if (DeptTypeEnum.TEAMS.getCode().equals(dept.getDeptType())) {
237
             List<SysUser> users = userMapper.selectUsersByDeptId(dept.getDeptId());
237
             List<SysUser> users = userMapper.selectUsersByDeptId(dept.getDeptId());
@@ -242,11 +242,11 @@ public class SysDeptServiceImpl implements ISysDeptService {
242
                 children.addAll(userChildren);
242
                 children.addAll(userChildren);
243
             }
243
             }
244
         }
244
         }
245
-        
245
+
246
         if (!children.isEmpty()) {
246
         if (!children.isEmpty()) {
247
             treeSelect.setChildren(new ArrayList<>(children));
247
             treeSelect.setChildren(new ArrayList<>(children));
248
         }
248
         }
249
-        
249
+
250
         return treeSelect;
250
         return treeSelect;
251
     }
251
     }
252
 
252
 
@@ -507,7 +507,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
507
         List<SysUser> result = Collections.emptyList();
507
         List<SysUser> result = Collections.emptyList();
508
         if (StringUtils.equals(DeptTypeEnum.STATION.getCode(), sysDept.getDeptType())) {
508
         if (StringUtils.equals(DeptTypeEnum.STATION.getCode(), sysDept.getDeptType())) {
509
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.test.getCode());
509
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.test.getCode());
510
-        } else if (StringUtils.equals(DeptTypeEnum.DEPARTMENT.getCode(), sysDept.getDeptType())) {
510
+        } else if (StringUtils.equals(DeptTypeEnum.BRIGADE.getCode(), sysDept.getDeptType())) {
511
+            result = deptMapper.deptLeader(deptId, RoleTypeEnum.jingli.getCode());
512
+        } else if (StringUtils.equals(DeptTypeEnum.MANAGER.getCode(), sysDept.getDeptType())) {
511
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.kezhang.getCode());
513
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.kezhang.getCode());
512
         } else if (StringUtils.equals(DeptTypeEnum.TEAMS.getCode(), sysDept.getDeptType())) {
514
         } else if (StringUtils.equals(DeptTypeEnum.TEAMS.getCode(), sysDept.getDeptType())) {
513
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.banzuzhang.getCode());
515
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.banzuzhang.getCode());
@@ -547,4 +549,20 @@ public class SysDeptServiceImpl implements ISysDeptService {
547
     public List<SysDept> selectDeptInfoAll(SysDept dept) {
549
     public List<SysDept> selectDeptInfoAll(SysDept dept) {
548
         return deptMapper.selectDeptList(dept);
550
         return deptMapper.selectDeptList(dept);
549
     }
551
     }
552
+
553
+    /**
554
+     * 查询部门指定角色人员
555
+     *
556
+     * @param deptId 部门ID
557
+     * @return 指定角色人员
558
+     */
559
+    @Override
560
+    public List<SysUser> deptRole(Long deptId, List<String> roleKeyList) {
561
+        SysDept sysDept = deptMapper.selectDeptById(deptId);
562
+        if (ObjectUtil.isNull(sysDept)) {
563
+            throw new ServiceException("操作失败,部门ID【" + deptId + "】不存在");
564
+        }
565
+        List<SysUser> result = deptMapper.deptRole(deptId, roleKeyList);
566
+        return result;
567
+    }
550
 }
568
 }

+ 18 - 5
airport-system/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -228,20 +228,21 @@
228
           and sr.role_key = #{roleType}
228
           and sr.role_key = #{roleType}
229
     </select>
229
     </select>
230
 
230
 
231
-    <select id="selectDeptInfo" parameterType="com.sundot.airport.common.core.domain.entity.SysDept"  resultMap="SysDeptResult">
231
+    <select id="selectDeptInfo" parameterType="com.sundot.airport.common.core.domain.entity.SysDept"
232
+            resultMap="SysDeptResult">
232
         SELECT *
233
         SELECT *
233
         FROM sys_dept
234
         FROM sys_dept
234
         WHERE FIND_IN_SET(#{deptId}, ancestors)
235
         WHERE FIND_IN_SET(#{deptId}, ancestors)
235
-        <if test="deptType != null and deptType != ''"> and dept_type = #{deptType} </if>
236
-          and del_flag = '0'
236
+        <if test="deptType != null and deptType != ''">and dept_type = #{deptType}</if>
237
+        and del_flag = '0'
237
         union all
238
         union all
238
         SELECT *
239
         SELECT *
239
         FROM sys_dept
240
         FROM sys_dept
240
         WHERE dept_id = #{deptId}
241
         WHERE dept_id = #{deptId}
241
-          and del_flag = '0'
242
+        and del_flag = '0'
242
     </select>
243
     </select>
243
 
244
 
244
-    <select id="selectDeptByIdList"  resultMap="SysDeptResult">
245
+    <select id="selectDeptByIdList" resultMap="SysDeptResult">
245
         select d.dept_id,
246
         select d.dept_id,
246
         d.parent_id,
247
         d.parent_id,
247
         d.ancestors,
248
         d.ancestors,
@@ -260,4 +261,16 @@
260
             #{item}
261
             #{item}
261
         </foreach>
262
         </foreach>
262
     </select>
263
     </select>
264
+
265
+    <select id="deptRole" resultType="com.sundot.airport.common.core.domain.entity.SysUser">
266
+        select su.*
267
+        from sys_user su
268
+        inner join sys_user_role sur on su.user_id = sur.user_id
269
+        inner join sys_role sr on sr.role_id = sur.role_id
270
+        where su.dept_id = #{deptId}
271
+        and sr.role_key in
272
+        <foreach collection="list" item="item" open="(" separator="," close=")">
273
+            #{item}
274
+        </foreach>
275
+    </select>
263
 </mapper> 
276
 </mapper>