提交 | 用户 | 时间
|
e7c126
|
1 |
package com.iailab.module.system.api.user; |
H |
2 |
|
|
3 |
import cn.hutool.core.convert.Convert; |
0f60af
|
4 |
import com.fhs.core.trans.anno.AutoTrans; |
e7c126
|
5 |
import com.iailab.framework.common.pojo.CommonResult; |
H |
6 |
import com.iailab.framework.common.util.collection.CollectionUtils; |
|
7 |
import com.iailab.module.system.api.user.dto.AdminUserRespDTO; |
|
8 |
import com.iailab.module.system.enums.ApiConstants; |
|
9 |
import com.fhs.trans.service.AutoTransable; |
|
10 |
import io.swagger.v3.oas.annotations.tags.Tag; |
|
11 |
import io.swagger.v3.oas.annotations.Parameter; |
|
12 |
import io.swagger.v3.oas.annotations.Operation; |
|
13 |
import org.springframework.cloud.openfeign.FeignClient; |
|
14 |
import org.springframework.web.bind.annotation.GetMapping; |
d9f9ba
|
15 |
import org.springframework.web.bind.annotation.PostMapping; |
H |
16 |
import org.springframework.web.bind.annotation.RequestBody; |
e7c126
|
17 |
import org.springframework.web.bind.annotation.RequestParam; |
0f60af
|
18 |
import static com.iailab.module.system.api.user.AdminUserApi.PREFIX; |
e7c126
|
19 |
|
H |
20 |
import java.util.*; |
|
21 |
|
1ecdfb
|
22 |
@FeignClient(name = ApiConstants.NAME) |
e7c126
|
23 |
@Tag(name = "RPC 服务 - 管理员用户") |
0f60af
|
24 |
@AutoTrans(namespace = PREFIX, fields = {"nickname"}) // TODO @iailab:需要 easy-trans 做个 bugfix |
e7c126
|
25 |
public interface AdminUserApi extends AutoTransable<AdminUserRespDTO> { |
H |
26 |
|
|
27 |
String PREFIX = ApiConstants.PREFIX + "/user"; |
|
28 |
|
|
29 |
@GetMapping(PREFIX + "/get") |
|
30 |
@Operation(summary = "通过用户 ID 查询用户") |
|
31 |
@Parameter(name = "id", description = "用户编号", example = "1", required = true) |
|
32 |
CommonResult<AdminUserRespDTO> getUser(@RequestParam("id") Long id); |
|
33 |
|
|
34 |
@GetMapping(PREFIX + "/list-by-subordinate") |
|
35 |
@Operation(summary = "通过用户 ID 查询用户下属") |
|
36 |
@Parameter(name = "id", description = "用户编号", example = "1", required = true) |
|
37 |
CommonResult<List<AdminUserRespDTO>> getUserListBySubordinate(@RequestParam("id") Long id); |
|
38 |
|
|
39 |
@GetMapping(PREFIX + "/list") |
|
40 |
@Operation(summary = "通过用户 ID 查询用户们") |
|
41 |
@Parameter(name = "ids", description = "部门编号数组", example = "1,2", required = true) |
|
42 |
CommonResult<List<AdminUserRespDTO>> getUserList(@RequestParam("ids") Collection<Long> ids); |
|
43 |
|
|
44 |
@GetMapping(PREFIX + "/list-by-dept-id") |
|
45 |
@Operation(summary = "获得指定部门的用户数组") |
|
46 |
@Parameter(name = "deptIds", description = "部门编号数组", example = "1,2", required = true) |
|
47 |
CommonResult<List<AdminUserRespDTO>> getUserListByDeptIds(@RequestParam("deptIds") Collection<Long> deptIds); |
|
48 |
|
|
49 |
@GetMapping(PREFIX + "/list-by-post-id") |
|
50 |
@Operation(summary = "获得指定岗位的用户数组") |
|
51 |
@Parameter(name = "postIds", description = "岗位编号数组", example = "2,3", required = true) |
|
52 |
CommonResult<List<AdminUserRespDTO>> getUserListByPostIds(@RequestParam("postIds") Collection<Long> postIds); |
|
53 |
|
|
54 |
/** |
|
55 |
* 获得用户 Map |
|
56 |
* |
|
57 |
* @param ids 用户编号数组 |
|
58 |
* @return 用户 Map |
|
59 |
*/ |
|
60 |
default Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids) { |
|
61 |
List<AdminUserRespDTO> users = getUserList(ids).getCheckedData(); |
|
62 |
return CollectionUtils.convertMap(users, AdminUserRespDTO::getId); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* 校验用户是否有效。如下情况,视为无效: |
|
67 |
* 1. 用户编号不存在 |
|
68 |
* 2. 用户被禁用 |
|
69 |
* |
|
70 |
* @param id 用户编号 |
|
71 |
*/ |
|
72 |
default void validateUser(Long id) { |
|
73 |
validateUserList(Collections.singleton(id)); |
|
74 |
} |
|
75 |
|
|
76 |
@GetMapping(PREFIX + "/valid") |
|
77 |
@Operation(summary = "校验用户们是否有效") |
|
78 |
@Parameter(name = "ids", description = "用户编号数组", example = "3,5", required = true) |
|
79 |
CommonResult<Boolean> validateUserList(@RequestParam("ids") Collection<Long> ids); |
|
80 |
|
|
81 |
@Override |
|
82 |
@GetMapping("select") |
|
83 |
default List<AdminUserRespDTO> selectByIds(List<?> ids) { |
|
84 |
return getUserList(Convert.toList(Long.class, ids)).getCheckedData(); |
|
85 |
} |
|
86 |
|
|
87 |
@Override |
|
88 |
@GetMapping("select-list") |
|
89 |
default AdminUserRespDTO selectById(Object id) { |
|
90 |
return getUser(Convert.toLong(id)).getCheckedData(); |
|
91 |
} |
|
92 |
|
d9f9ba
|
93 |
@Operation(summary = "Feign接口-保存或者修改用户") |
H |
94 |
@PostMapping("/api/feign/users/saveOrUpdate") |
|
95 |
void saveOrUpdateUserInfo(@RequestBody AdminUserRespDTO userRespDTO); |
|
96 |
|
e7c126
|
97 |
} |