SecurityController.ts
6.08 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
import {AxiosResponse, AxiosStatic} from 'axios';
import dayjs, {Dayjs} from 'dayjs';
// region 前端扩展导入包
import {TreeItem} from "autumn-vue/lib/core/bean/TreeItem";
import {Page} from "autumn-vue/lib/core/page/Page";
import {Role} from 'lib/src/entity/security/entity/Role';
import {User} from "lib/src/entity/security/entity/User";
// endregion
/**
*/
export class SecurityController {
/**
* 添加角色
* @param role
* @return Role
* @throws IOException
* @throws FieldException
*/
static addRole(axios: AxiosStatic, role: any): Promise<AxiosResponse<Role>> {
return axios.post('security/addRole', role);
}
/**
* 添加用户
* @param user
* @return User
* @throws FieldException
*/
static addUser(axios: AxiosStatic, user: any): Promise<AxiosResponse<User>> {
return axios.post('security/addUser', user);
}
/**
* 用户修改自己的密码
* @param userPassword
* @return boolean
*/
static changePassword(axios: AxiosStatic, userPassword: any): Promise<AxiosResponse<boolean>> {
return axios.post('security/changePassword', userPassword);
}
/**
*/
static enableUser(axios: AxiosStatic, userId: number, enabled: boolean): Promise<AxiosResponse<boolean>> {
return axios.post('security/enableUser', null, {params: {userId: userId, enabled: enabled}});
}
/**
*/
static enabledRole(axios: AxiosStatic, roleId: number, enabled: boolean): Promise<AxiosResponse<boolean>> {
return axios.post('security/enabledRole', null, {params: {roleId: roleId, enabled: enabled}});
}
/**
*/
static getEnabledRoles(axios: AxiosStatic): Promise<AxiosResponse<Role[]>> {
return axios.get('security/getEnabledRoles');
}
/**
*/
static getEnabledUsers(axios: AxiosStatic): Promise<AxiosResponse<User[]>> {
return axios.get('security/getEnabledUsers');
}
/**
*/
static getLoginUser(axios: AxiosStatic): Promise<AxiosResponse<User>> {
return axios.get('security/getLoginUser');
}
/**
*/
static getPrivilegeTreeByRoleId(axios: AxiosStatic, roleId: number): Promise<AxiosResponse<TreeItem[]>> {
return axios.get('security/getPrivilegeTreeByRoleId', {params: {roleId: roleId}});
}
/**
*/
static getRoleById(axios: AxiosStatic, roleId: number): Promise<AxiosResponse<Role>> {
return axios.get('security/getRoleById', {params: {roleId: roleId}});
}
/**
* 根据用户ID获取用户
* @param userId
* @return User
*/
static getUserById(axios: AxiosStatic, userId: number): Promise<AxiosResponse<User>> {
return axios.get('security/getUserById', {params: {userId: userId}});
}
/**
* 根据用户名获取用户
* @param userName
* @return User
*/
static getUserByUserName(axios: AxiosStatic, userName: string): Promise<AxiosResponse<User>> {
return axios.get('security/getUserByUserName', {params: {userName: userName}});
}
/**
*/
static pageRole(axios: AxiosStatic, pagination: any): Promise<AxiosResponse<Page<Role>>> {
return axios.post('security/pageRole', pagination);
}
static PAGE_ROLE = 'security/pageRole';
/**
* 分页查询用户
* @param pagination
* @return Page
*/
static pageUser(axios: AxiosStatic, pagination: any): Promise<AxiosResponse<Page<User>>> {
return axios.post('security/pageUser', pagination);
}
static PAGE_USER = 'security/pageUser';
/**
* 删除角色
* @param roleId
* @return int
* @throws IOException
*/
static removeRoleById(axios: AxiosStatic, roleId: number): Promise<AxiosResponse<number>> {
return axios.delete('security/removeRoleById', {params: {roleId: roleId}});
}
/**
* 根据用户ID删除用户
* @param userId
*/
static removeUserById(axios: AxiosStatic, userId: number): Promise<AxiosResponse<number>> {
return axios.delete('security/removeUserById', {params: {userId: userId}});
}
/**
* 管理员重置密码
* @param userPassword
* @return boolean
*/
static resetPassword(axios: AxiosStatic, userPassword: any): Promise<AxiosResponse<boolean>> {
return axios.post('security/resetPassword', userPassword);
}
/**
* 编辑个人信息
* @param user
* @return User
* @throws FieldException
*/
static updateProfile(axios: AxiosStatic, user: any): Promise<AxiosResponse<User>> {
return axios.post('security/updateProfile', user);
}
/**
* 修改角色
* @param role
* @return Role
* @throws FieldException
* @throws IOException
*/
static updateRole(axios: AxiosStatic, role: any): Promise<AxiosResponse<Role>> {
return axios.post('security/updateRole', role);
}
/**
* 修改角色权限
* @param role
* @return Role
* @throws FieldException
* @throws IOException
*/
static updateRolePrivileges(axios: AxiosStatic, role: any): Promise<AxiosResponse<Role>> {
return axios.post('security/updateRolePrivileges', role);
}
/**
*/
static updateRoleSetting(axios: AxiosStatic, role: any): Promise<AxiosResponse<Role>> {
return axios.post('security/updateRoleSetting', role);
}
/**
* 编辑用户
* @param user
* @return User
* @throws FieldException
*/
static updateUser(axios: AxiosStatic, user: any): Promise<AxiosResponse<User>> {
return axios.post('security/updateUser', user);
}
// region 前端扩展代码区
/**
*
* @return Authenticity
*/
static getUserAuthentication(axios: AxiosStatic, module: string | undefined | null): Promise<AxiosResponse> {
return axios.get('security/getUserAuthentication', {params: {module: module}});
}
static changeMobile(axios: AxiosStatic, mobile: string): Promise<AxiosResponse<User>> {
return axios.post('security/changeMobile', null, {params: {mobile: mobile}});
}
// endregion
}