ソースを参照

通过用户ID/组织id获取用户组织

wangxx 2 週間 前
コミット
e7cbfdf791

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

@@ -159,4 +159,22 @@ public class SysDeptController extends BaseController {
159 159
     public AjaxResult deptRole(@PathVariable Long deptId, @RequestBody List<String> roleKeyList) {
160 160
         return success(deptService.deptRole(deptId, roleKeyList));
161 161
     }
162
+
163
+    /**
164
+     * 通过用户ID获取用户组织信息
165
+     * GET /system/dept/userOrgInfo?userId=xxx
166
+     */
167
+    @GetMapping("/userOrgInfo")
168
+    public AjaxResult getUserOrgInfo(@RequestParam Long userId) {
169
+        return success(deptService.resolveOrgInfoByUserId(userId));
170
+    }
171
+
172
+    /**
173
+     * 通过部门ID获取部门组织信息及上级链
174
+     * GET /system/dept/deptOrgInfo?deptId=xxx
175
+     */
176
+    @GetMapping("/deptOrgInfo")
177
+    public AjaxResult getDeptOrgInfo(@RequestParam Long deptId) {
178
+        return success(deptService.getDeptInfoByDeptId(deptId));
179
+    }
162 180
 }

+ 6 - 6
airport-common/src/main/java/com/sundot/airport/common/dto/DeptInfo.java

@@ -16,32 +16,32 @@ public class DeptInfo implements Serializable {
16 16
     private static final long serialVersionUID = 1L;
17 17
 
18 18
     /**
19
-     * 组 id
19
+     * 组 id
20 20
      */
21 21
     private Long teamId;
22 22
 
23 23
     /**
24
-     * 组名称
24
+     * 组名称
25 25
      */
26 26
     private String teamName;
27 27
 
28 28
     /**
29
-     * 部门 id
29
+     * 班组 id
30 30
      */
31 31
     private Long departmentId;
32 32
 
33 33
     /**
34
-     * 部门名称
34
+     * 班组名称
35 35
      */
36 36
     private String departmentName;
37 37
 
38 38
     /**
39
-     * 大队 id
39
+     * 部门 id
40 40
      */
41 41
     private Long brigadeId;
42 42
 
43 43
     /**
44
-     * 大队名称
44
+     * 部门名称
45 45
      */
46 46
     private String brigadeName;
47 47
 

+ 18 - 0
airport-common/src/main/java/com/sundot/airport/common/dto/UserOrgInfo.java

@@ -0,0 +1,18 @@
1
+package com.sundot.airport.common.dto;
2
+
3
+import lombok.Data;
4
+
5
+import java.io.Serializable;
6
+
7
+/**
8
+ * 用户组织信息
9
+ */
10
+@Data
11
+public class UserOrgInfo implements Serializable {
12
+
13
+    private static final long serialVersionUID = 1L;
14
+
15
+    private Long userId;
16
+    private DeptInfo deptInfo;
17
+
18
+}

+ 3 - 3
airport-common/src/main/java/com/sundot/airport/common/enums/DeptType.java

@@ -13,10 +13,10 @@ import lombok.Getter;
13 13
 @AllArgsConstructor
14 14
 public enum DeptType {
15 15
     STATION("STATION", "机构站"),
16
-    BRIGADE("BRIGADE", "大队"),
17
-    MANAGER("MANAGER", "主管"),
16
+    BRIGADE("BRIGADE", "部门"),
17
+    MANAGER("MANAGER", "班组"),
18 18
     DEPARTMENT("DEPARTMENT", "科室"),
19
-    TEAMS("TEAMS", "组"),
19
+    TEAMS("TEAMS", "组"),
20 20
     ;
21 21
 
22 22
     private final String code;

+ 9 - 0
airport-system/src/main/java/com/sundot/airport/system/service/ISysDeptService.java

@@ -7,6 +7,7 @@ import com.sundot.airport.common.core.domain.DeptUserTreeSelect;
7 7
 import com.sundot.airport.common.core.domain.entity.SysDept;
8 8
 import com.sundot.airport.common.core.domain.entity.SysUser;
9 9
 import com.sundot.airport.common.dto.DeptInfo;
10
+import com.sundot.airport.common.dto.UserOrgInfo;
10 11
 
11 12
 /**
12 13
  * 部门管理 服务层
@@ -196,4 +197,12 @@ public interface ISysDeptService {
196 197
      * @return 部门列表
197 198
      */
198 199
     public List<SysDept> selectChildrenDeptById(Long deptId);
200
+
201
+    /**
202
+     * 通过用户ID获取用户组织信息
203
+     *
204
+     * @param userId 用户ID
205
+     * @return 用户组织信息
206
+     */
207
+    public UserOrgInfo resolveOrgInfoByUserId(Long userId);
199 208
 }

+ 18 - 0
airport-system/src/main/java/com/sundot/airport/system/service/impl/SysDeptServiceImpl.java

@@ -12,6 +12,7 @@ import cn.hutool.core.util.ObjectUtil;
12 12
 import cn.hutool.core.util.StrUtil;
13 13
 import com.sundot.airport.common.config.LevelConfig;
14 14
 import com.sundot.airport.common.dto.DeptInfo;
15
+import com.sundot.airport.common.dto.UserOrgInfo;
15 16
 import com.sundot.airport.common.enums.DeptType;
16 17
 import com.sundot.airport.common.enums.DeptTypeEnum;
17 18
 import com.sundot.airport.common.enums.RoleTypeEnum;
@@ -609,4 +610,21 @@ public class SysDeptServiceImpl implements ISysDeptService {
609 610
     public List<SysDept> selectChildrenDeptById(Long deptId) {
610 611
         return deptMapper.selectUseChildrenDeptById(deptId);
611 612
     }
613
+
614
+    @Override
615
+    public UserOrgInfo resolveOrgInfoByUserId(Long userId) {
616
+        UserOrgInfo result = new UserOrgInfo();
617
+        if (userId == null) {
618
+            return result;
619
+        }
620
+        result.setUserId(userId);
621
+
622
+        SysUser user = userMapper.selectUserById(userId);
623
+        if (user == null || user.getDeptId() == null) {
624
+            return result;
625
+        }
626
+
627
+        result.setDeptInfo(getDeptInfoByDeptId(user.getDeptId()));
628
+        return result;
629
+    }
612 630
 }