user.ts
1.6 KB
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
import { ApiClient } from '../core/client';
export interface UserPageParams {
current?: number;
size?: number;
keyword?: string;
mobile?: string;
orgId?: number;
roleId?: number;
status?: number;
}
export interface UserPageItem {
userId: number;
account: string;
name: string;
mobile: string;
email?: string;
orgId?: number;
orgPath?: string;
dataScope?: number;
dataScopeLabel?: string;
status: number;
lastLoginAt?: string;
roleNames?: string[];
roleCodes?: string[];
remark?: string;
}
export interface UserCreatePayload {
account: string;
name: string;
mobile: string;
email?: string;
orgId: number;
dataScope?: number;
status?: number;
roleIds?: number[];
remark?: string;
}
export interface UserUpdatePayload extends Omit<UserCreatePayload, 'account'> {
userId: number;
}
export interface UserPageResult {
records: UserPageItem[];
total: number;
current: number;
size: number;
pages: number;
}
class User extends ApiClient {
page(params: UserPageParams) {
return this.post<UserPageResult>('/system/user/page', params);
}
create(payload: UserCreatePayload) {
return this.post<null>('/system/user/create', payload);
}
update(payload: UserUpdatePayload) {
return this.post<null>('/system/user/update', payload);
}
resetPassword(userId: number, payload: { password: string }) {
return this.post<null>(`/system/user/${userId}/reset-password`, payload);
}
updateStatus(userId: number, payload: { status: number }) {
return this.post<null>(`/system/user/${userId}/status`, payload);
}
}
export const user = new User();