chenshudong 4 місяців тому
батько
коміт
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 151
     public AjaxResult deptLeader(@PathVariable Long deptId) {
152 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 11
 public enum DeptTypeEnum {
12 12
 
13 13
     STATION("STATION", "机构站"),
14
+    BRIGADE("BRIGADE", "大队"),
15
+    MANAGER("MANAGER", "主管"),
14 16
     DEPARTMENT("DEPARTMENT", "科室"),
15 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 148
      * @return 部门信息
149 149
      */
150 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 1
 package com.sundot.airport.system.service;
2 2
 
3 3
 import java.util.List;
4
+
4 5
 import com.sundot.airport.common.core.domain.TreeSelect;
5 6
 import com.sundot.airport.common.core.domain.DeptUserTreeSelect;
6 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 13
  * @author ruoyi
13 14
  */
14
-public interface ISysDeptService
15
-{
15
+public interface ISysDeptService {
16 16
     /**
17 17
      * 查询部门管理数据
18
-     * 
18
+     *
19 19
      * @param dept 部门信息
20 20
      * @return 部门信息集合
21 21
      */
@@ -23,7 +23,7 @@ public interface ISysDeptService
23 23
 
24 24
     /**
25 25
      * 查询部门树结构信息
26
-     * 
26
+     *
27 27
      * @param dept 部门信息
28 28
      * @return 部门树信息集合
29 29
      */
@@ -39,7 +39,7 @@ public interface ISysDeptService
39 39
 
40 40
     /**
41 41
      * 根据角色ID查询部门树信息
42
-     * 
42
+     *
43 43
      * @param roleId 角色ID
44 44
      * @return 选中部门列表
45 45
      */
@@ -47,7 +47,7 @@ public interface ISysDeptService
47 47
 
48 48
     /**
49 49
      * 根据部门ID查询信息
50
-     * 
50
+     *
51 51
      * @param deptId 部门ID
52 52
      * @return 部门信息
53 53
      */
@@ -55,7 +55,7 @@ public interface ISysDeptService
55 55
 
56 56
     /**
57 57
      * 根据ID查询所有子部门(正常状态)
58
-     * 
58
+     *
59 59
      * @param deptId 部门ID
60 60
      * @return 子部门数
61 61
      */
@@ -63,7 +63,7 @@ public interface ISysDeptService
63 63
 
64 64
     /**
65 65
      * 是否存在子节点
66
-     * 
66
+     *
67 67
      * @param deptId 部门ID
68 68
      * @return 结果
69 69
      */
@@ -71,7 +71,7 @@ public interface ISysDeptService
71 71
 
72 72
     /**
73 73
      * 查询部门是否存在用户
74
-     * 
74
+     *
75 75
      * @param deptId 部门ID
76 76
      * @return 结果 true 存在 false 不存在
77 77
      */
@@ -79,7 +79,7 @@ public interface ISysDeptService
79 79
 
80 80
     /**
81 81
      * 校验部门名称是否唯一
82
-     * 
82
+     *
83 83
      * @param dept 部门信息
84 84
      * @return 结果
85 85
      */
@@ -87,14 +87,14 @@ public interface ISysDeptService
87 87
 
88 88
     /**
89 89
      * 校验部门是否有数据权限
90
-     * 
90
+     *
91 91
      * @param deptId 部门id
92 92
      */
93 93
     public void checkDeptDataScope(Long deptId);
94 94
 
95 95
     /**
96 96
      * 新增保存部门信息
97
-     * 
97
+     *
98 98
      * @param dept 部门信息
99 99
      * @return 结果
100 100
      */
@@ -102,7 +102,7 @@ public interface ISysDeptService
102 102
 
103 103
     /**
104 104
      * 修改保存部门信息
105
-     * 
105
+     *
106 106
      * @param dept 部门信息
107 107
      * @return 结果
108 108
      */
@@ -110,7 +110,7 @@ public interface ISysDeptService
110 110
 
111 111
     /**
112 112
      * 删除部门管理信息
113
-     * 
113
+     *
114 114
      * @param deptId 部门ID
115 115
      * @return 结果
116 116
      */
@@ -158,7 +158,7 @@ public interface ISysDeptService
158 158
 
159 159
     /**
160 160
      * 构建前端所需要树结构
161
-     * 
161
+     *
162 162
      * @param depts 部门列表
163 163
      * @return 树结构列表
164 164
      */
@@ -166,9 +166,17 @@ public interface ISysDeptService
166 166
 
167 167
     /**
168 168
      * 构建前端所需要下拉树结构
169
-     * 
169
+     *
170 170
      * @param depts 部门列表
171 171
      * @return 下拉树结构列表
172 172
      */
173 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 121
      * @param deptId 部门ID
122 122
      * @return 包含指定部门及其所有子部门的树
123 123
      */
@@ -222,16 +222,16 @@ public class SysDeptServiceImpl implements ISysDeptService {
222 222
      */
223 223
     private DeptUserTreeSelect convertDeptToDeptUserTreeSelect(SysDept dept) {
224 224
         DeptUserTreeSelect treeSelect = new DeptUserTreeSelect(dept);
225
-        
225
+
226 226
         List<DeptUserTreeSelect> children = new ArrayList<>();
227
-        
227
+
228 228
         // 处理子部门
229 229
         if (dept.getChildren() != null && !dept.getChildren().isEmpty()) {
230 230
             children.addAll(dept.getChildren().stream()
231 231
                     .map(this::convertDeptToDeptUserTreeSelect)
232 232
                     .collect(Collectors.toList()));
233 233
         }
234
-        
234
+
235 235
         // 如果是班组类型,则添加用户节点
236 236
         if (DeptTypeEnum.TEAMS.getCode().equals(dept.getDeptType())) {
237 237
             List<SysUser> users = userMapper.selectUsersByDeptId(dept.getDeptId());
@@ -242,11 +242,11 @@ public class SysDeptServiceImpl implements ISysDeptService {
242 242
                 children.addAll(userChildren);
243 243
             }
244 244
         }
245
-        
245
+
246 246
         if (!children.isEmpty()) {
247 247
             treeSelect.setChildren(new ArrayList<>(children));
248 248
         }
249
-        
249
+
250 250
         return treeSelect;
251 251
     }
252 252
 
@@ -507,7 +507,9 @@ public class SysDeptServiceImpl implements ISysDeptService {
507 507
         List<SysUser> result = Collections.emptyList();
508 508
         if (StringUtils.equals(DeptTypeEnum.STATION.getCode(), sysDept.getDeptType())) {
509 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 513
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.kezhang.getCode());
512 514
         } else if (StringUtils.equals(DeptTypeEnum.TEAMS.getCode(), sysDept.getDeptType())) {
513 515
             result = deptMapper.deptLeader(deptId, RoleTypeEnum.banzuzhang.getCode());
@@ -547,4 +549,20 @@ public class SysDeptServiceImpl implements ISysDeptService {
547 549
     public List<SysDept> selectDeptInfoAll(SysDept dept) {
548 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 228
           and sr.role_key = #{roleType}
229 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 233
         SELECT *
233 234
         FROM sys_dept
234 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 238
         union all
238 239
         SELECT *
239 240
         FROM sys_dept
240 241
         WHERE dept_id = #{deptId}
241
-          and del_flag = '0'
242
+        and del_flag = '0'
242 243
     </select>
243 244
 
244
-    <select id="selectDeptByIdList"  resultMap="SysDeptResult">
245
+    <select id="selectDeptByIdList" resultMap="SysDeptResult">
245 246
         select d.dept_id,
246 247
         d.parent_id,
247 248
         d.ancestors,
@@ -260,4 +261,16 @@
260 261
             #{item}
261 262
         </foreach>
262 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 276
 </mapper>