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