gaoluyang
3 天以前 d39e4f7d839167c16425086dfa2f8747bccfdff9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package cn.iocoder.yudao.module.system.api.user;
 
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserCreateReqDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserUpdateReqDTO;
 
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
 
/**
 * Admin 用户 API 接口
 *
 * @author 超级管理员
 */
public interface AdminUserApi {
 
    /**
     * 创建用户
     *
     * @param createReqDTO 用户创建信息
     * @return 用户编号
     */
    Long createUser(AdminUserCreateReqDTO createReqDTO);
 
    /**
     * 更新用户(供其他模块同步更新系统用户部分信息,如岗位/部门/昵称等)
     *
     * @param updateReqDTO 用户更新信息
     */
    void updateUser(AdminUserUpdateReqDTO updateReqDTO);
 
    /**
     * 更新用户状态(开启 / 停用)
     *
     * @param id     用户编号
     * @param status 状态,见 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
     */
    void updateUserStatus(Long id, Integer status);
 
    /**
     * 通过用户 ID 查询用户
     *
     * @param id 用户ID
     * @return 用户对象信息
     */
    AdminUserRespDTO getUser(Long id);
 
    /**
     * 通过用户 ID 查询用户下属
     *
     * @param id 用户编号
     * @return 用户下属用户列表
     */
    List<AdminUserRespDTO> getUserListBySubordinate(Long id);
 
    /**
     * 通过用户 ID 查询用户们
     *
     * @param ids 用户 ID 们
     * @return 用户对象信息
     */
    List<AdminUserRespDTO> getUserList(Collection<Long> ids);
 
    /**
     * 获得指定部门的用户数组
     *
     * @param deptIds 部门数组
     * @return 用户数组
     */
    List<AdminUserRespDTO> getUserListByDeptIds(Collection<Long> deptIds);
 
    /**
     * 获得指定岗位的用户数组
     *
     * @param postIds 岗位数组
     * @return 用户数组
     */
    List<AdminUserRespDTO> getUserListByPostIds(Collection<Long> postIds);
 
    /**
     * 根据昵称模糊搜索用户
     *
     * @param nickname 昵称关键词
     * @return 用户列表
     */
    List<AdminUserRespDTO> getUserListByNickname(String nickname);
 
    /**
     * 根据账号模糊搜索用户
     *
     * @param username 账号关键词
     * @return 用户列表
     */
    List<AdminUserRespDTO> getUserListByUsername(String username);
 
    /**
     * 获得用户 Map
     *
     * @param ids 用户编号数组
     * @return 用户 Map
     */
    default Map<Long, AdminUserRespDTO> getUserMap(Collection<Long> ids) {
        List<AdminUserRespDTO> users = getUserList(ids);
        return CollectionUtils.convertMap(users, AdminUserRespDTO::getId);
    }
 
    /**
     * 校验用户是否有效。如下情况,视为无效:
     * 1. 用户编号不存在
     * 2. 用户被禁用
     *
     * @param id 用户编号
     */
    default void validateUser(Long id) {
        validateUserList(Collections.singleton(id));
    }
 
    /**
     * 校验用户们是否有效。如下情况,视为无效:
     * 1. 用户编号不存在
     * 2. 用户被禁用
     *
     * @param ids 用户编号数组
     */
    void validateUserList(Collection<Long> ids);
 
}