Files
FastapiAdmin/frontend/web/src/api/module_system/user.ts
T
zhangtao 5ff72b086f refactor: 重构项目模块结构与代码细节优化
1.  调整后端模块路由与插件文件结构,迁移部分模块代码至api/v1目录
2.  优化代码注释格式与文档字符串,简化冗余代码
3.  添加监控仪表盘、工单评论等新模块功能
4.  修复前端部分组件交互逻辑与类型定义
5.  清理冗余的初始化数据与废弃配置文件
6.  新增租户注册表单字段与国际化支持
7.  优化HTTP请求拦截器与快捷键功能
2026-07-10 00:18:11 +08:00

278 lines
5.8 KiB
TypeScript

import { request } from "@utils";
import { MenuTable, MenuForm } from "@/api/module_platform/menu";
const API_PATH = "/system/user";
export const UserAPI = {
getCurrentUserInfo() {
return request<ApiResponse<UserInfo>>({
url: `${API_PATH}/current/info`,
method: "get",
});
},
uploadCurrentUserAvatar(body: any) {
return request<ApiResponse<UploadFilePath>>({
url: `/common/file/upload?upload_type=avatar`,
method: "post",
data: body,
headers: { "Content-Type": "multipart/form-data" },
});
},
updateCurrentUserInfo(body: InfoFormState) {
return request<ApiResponse<UserInfo>>({
url: `${API_PATH}/current/info/update`,
method: "put",
data: body,
});
},
changeCurrentUserPassword(body: PasswordFormState) {
return request<ApiResponse>({
url: `${API_PATH}/current/password/change`,
method: "put",
data: body,
});
},
resetUserPassword(id: number, body: ResetPasswordForm) {
return request<ApiResponse>({
url: `${API_PATH}/password/reset/${id}`,
method: "put",
data: body,
});
},
forgetPassword(body: ForgetPasswordForm) {
return request<ApiResponse>({
url: `${API_PATH}/password/forget`,
method: "post",
data: body,
});
},
listUser(query: UserPageQuery) {
return request<ApiResponse<PageResult<UserInfo>>>({
url: `${API_PATH}/list`,
method: "get",
params: query,
});
},
detailUser(id: number) {
return request<ApiResponse<UserInfo>>({
url: `${API_PATH}/detail/${id}`,
method: "get",
});
},
createUser(body: UserForm) {
return request<ApiResponse>({
url: `${API_PATH}/create`,
method: "post",
data: body,
});
},
updateUser(id: number, body: UserForm) {
return request<ApiResponse>({
url: `${API_PATH}/update/${id}`,
method: "put",
data: body,
});
},
deleteUser(body: number[]) {
return request<ApiResponse>({
url: `${API_PATH}/delete`,
method: "delete",
data: body,
});
},
batchUser(body: BatchType) {
return request<ApiResponse>({
url: `${API_PATH}/status/batch`,
method: "patch",
data: body,
});
},
exportUser(query: UserPageQuery) {
return request<Blob>({
url: `${API_PATH}/export`,
method: "get",
params: query,
responseType: "blob",
});
},
downloadTemplateUser() {
return request<ApiResponse>({
url: `${API_PATH}/import/template`,
method: "get",
responseType: "blob",
});
},
importUser(body: any) {
return request<ApiResponse>({
url: `${API_PATH}/import/data`,
method: "post",
data: body,
headers: {
"Content-Type": "multipart/form-data",
},
});
},
};
export default UserAPI;
export interface ForgetPasswordForm {
tenant_name: string;
username: string;
new_password: string;
mobile?: string;
confirmPassword: string;
}
export interface RegisterForm {
tenant_name: string;
username: string;
password: string;
confirmPassword: string;
email?: string;
}
export interface UserPageQuery extends PageQuery, UserByQueryParams, TenantByQueryParams {
username?: string;
name?: string;
mobile?: string;
email?: string;
dept_id?: number;
}
export interface searchSelectDataType {
name?: string;
status?: number;
}
export interface UserInfo extends BaseType {
username?: string;
name?: string;
avatar?: string;
email?: string;
mobile?: string;
gender?: string;
password?: string;
menus?: MenuTable[];
dept?: deptTreeType;
dept_id?: deptTreeType["id"];
dept_name?: deptTreeType["name"];
roles?: roleSelectorType[];
role_names?: roleSelectorType["name"][];
role_ids?: roleSelectorType["id"][];
positions?: positionSelectorType[];
position_names?: positionSelectorType["name"][];
position_ids?: positionSelectorType["id"][];
is_superuser?: boolean;
is_impersonate?: boolean;
last_login?: string;
created_by?: CommonType;
updated_by?: CommonType;
deleted_by?: CommonType;
tenant_by?: CommonType;
gitee_login?: string;
github_login?: string;
wx_login?: string;
qq_login?: string;
status?: number;
description?: string;
}
export interface deptTreeType {
id?: number;
name?: string;
parent_id?: number;
children?: deptTreeType[];
}
export interface roleSelectorType {
id?: number;
name?: string;
code?: string;
status?: number;
description?: string;
menus?: MenuForm[];
}
export interface positionSelectorType {
id?: number;
name?: string;
status?: number;
description?: string;
}
export interface InfoFormState {
id?: number;
name?: string;
gender?: number;
mobile?: string;
email?: string;
username?: string;
dept_name?: string;
dept?: deptTreeType;
positions?: positionSelectorType[];
roles?: roleSelectorType[];
avatar?: string;
created_time?: string;
updated_time?: string;
status?: number;
description?: string;
tenant_by?: CommonType;
gitee_login?: string;
github_login?: string;
wx_login?: string;
qq_login?: string;
}
export interface PasswordFormState {
old_password: string;
new_password: string;
confirm_password: string;
}
export interface ResetPasswordForm {
password: string;
}
export interface UserForm extends BaseFormType {
username?: string;
name?: string;
dept_id?: number;
dept_name?: string;
role_ids?: number[];
role_names?: string[];
position_ids?: number[];
position_names?: string[];
password?: string;
gender?: number;
email?: string;
mobile?: string;
is_superuser?: boolean;
avatar?: string;
tenant_id?: number;
status?: number;
description?: string;
}
export interface CurrentUserFormState {
name?: string;
gender?: number;
mobile?: string;
email?: string;
avatar?: string;
}