xiaoyi
5 天以前 481d8165f26fc7e37f0e87f6444ac0340bb563a3
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
131
132
133
134
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.AdminUserSyncReqDTO;
 
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 id 用户编号
     * @param password 明文密码
     */
    void updateUserPassword(Long id, String password);
 
    /**
     * 删除用户,但**不发布** {@code AdminUserDeletedEvent}
     *
     * 供 hrm 模块删除员工时联动删除账号,避免事件回环(员工删 → 账号删 → 员工删)。
     *
     * @param id 用户编号
     */
    void deleteUserSilently(Long id);
 
    /**
     * 将员工档案字段同步到系统账号,但**不发布** {@code AdminUserUpdatedEvent}
     *
     * 供 hrm 模块修改员工时反向同步账号,避免事件回环。
     * 只更新 DTO 中非空的字段。
     *
     * @param reqDTO 同步信息
     */
    void updateUserForEmployee(AdminUserSyncReqDTO reqDTO);
 
    /**
     * 通过用户 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);
 
    /**
     * 获得用户 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);
 
}