65 lines
1.3 KiB
TypeScript
65 lines
1.3 KiB
TypeScript
import type { Recordable } from '@vben/types';
|
|
|
|
import { requestClient } from '#/api/request';
|
|
|
|
export namespace SystemUserApi {
|
|
export interface SystemUser {
|
|
[key: string]: any;
|
|
id: string;
|
|
name: string;
|
|
permissions: string[];
|
|
remark?: string;
|
|
status: 0 | 1;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 获取角色列表数据
|
|
*/
|
|
async function getUserList(params: Recordable<any>) {
|
|
return requestClient.get<Array<SystemUserApi.SystemUser>>('/user/list', {
|
|
params,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* 创建角色
|
|
* @param data 角色数据
|
|
*/
|
|
async function createUser(data: Omit<SystemUserApi.SystemUser, 'id'>) {
|
|
return requestClient.post('/user/create', data);
|
|
}
|
|
|
|
/**
|
|
* 更新角色
|
|
*
|
|
* @param id 角色 ID
|
|
* @param data 角色数据
|
|
*/
|
|
async function updateUser(
|
|
id: string,
|
|
data: Omit<SystemUserApi.SystemUser, 'id'>,
|
|
) {
|
|
return requestClient.put(`/user/update/${id}`, data);
|
|
}
|
|
|
|
/**
|
|
* 删除角色
|
|
* @param id 角色 ID
|
|
*/
|
|
async function deleteUser(id: string) {
|
|
return requestClient.delete(`/user/delete/${id}`);
|
|
}
|
|
|
|
/**
|
|
* 重置用户密码
|
|
* @param id 用户 ID
|
|
* @param data 新密码数据
|
|
* @param data.password 新密码
|
|
*/
|
|
async function resetPassword(id: string, data: { password: string }) {
|
|
return requestClient.post(`/reset-password/${id}`, data);
|
|
}
|
|
|
|
export { createUser, deleteUser, getUserList, resetPassword, updateUser };
|