mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-14 05:00:10 +00:00
feat(auth): 添加第三方OAuth登录支持
- 实现OAuth登录重定向和回调处理 - 更新配置文件以支持多种OAuth提供商 - 添加错误处理和状态管理功能 - 更新文档以反映新功能和配置要求
This commit is contained in:
@@ -1,29 +1,53 @@
|
||||
import request from '@/utils/http'
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param params 登录参数
|
||||
* @returns 登录响应
|
||||
* 认证相关便捷接口(示例页等使用 `@/api/auth` 路径导入)
|
||||
* 实现委托至 `@/api/module_system/auth` / `user`
|
||||
*/
|
||||
export function fetchLogin(params: Api.Auth.LoginParams) {
|
||||
return request.post<Api.Auth.LoginResponse>({
|
||||
url: '/api/auth/login',
|
||||
params
|
||||
// showSuccessMessage: true // 显示成功消息
|
||||
// showErrorMessage: false // 不显示错误消息
|
||||
})
|
||||
import AuthAPI, { type LoginFormData } from "@/api/module_system/auth";
|
||||
import UserAPI, { type UserInfo } from "@/api/module_system/user";
|
||||
import { ResultEnum } from "@/enums/api/result.enum";
|
||||
|
||||
export interface FetchLoginParams {
|
||||
userName: string;
|
||||
password: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @returns 用户信息
|
||||
*/
|
||||
export function fetchGetUserInfo() {
|
||||
return request.get<Api.Auth.UserInfo>({
|
||||
url: '/api/user/info'
|
||||
// 自定义请求头
|
||||
// headers: {
|
||||
// 'X-Custom-Header': 'your-custom-value'
|
||||
// }
|
||||
})
|
||||
export async function fetchLogin(params: FetchLoginParams): Promise<{
|
||||
token: string;
|
||||
refreshToken: string;
|
||||
}> {
|
||||
const captchaRes = await AuthAPI.getCaptcha();
|
||||
const captchaInfo = captchaRes.data?.data;
|
||||
|
||||
const loginForm: LoginFormData = {
|
||||
username: params.userName,
|
||||
password: params.password,
|
||||
captcha_key: captchaInfo?.key ?? "",
|
||||
captcha: "",
|
||||
remember: false,
|
||||
login_type: "PC端",
|
||||
};
|
||||
|
||||
const response = await AuthAPI.login(loginForm);
|
||||
if (response.data.code !== ResultEnum.SUCCESS || !response.data.data) {
|
||||
throw new Error(response.data.msg || "登录失败");
|
||||
}
|
||||
|
||||
const data = response.data.data;
|
||||
return {
|
||||
token: data.access_token,
|
||||
refreshToken: data.refresh_token,
|
||||
};
|
||||
}
|
||||
|
||||
/** 使用当前请求上下文中的 token 拉取用户信息(与 store.getUserInfo 数据来源一致) */
|
||||
export async function fetchGetUserInfo(): Promise<UserInfo> {
|
||||
const response = await UserAPI.getCurrentUserInfo();
|
||||
if (response.data.code !== ResultEnum.SUCCESS || response.data.data == null) {
|
||||
throw new Error(response.data.msg || "获取用户信息失败");
|
||||
}
|
||||
|
||||
const raw = response.data.data;
|
||||
const next = { ...raw };
|
||||
delete next.menus;
|
||||
return next as UserInfo;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/ai/chat";
|
||||
|
||||
export const AiChatAPI = {
|
||||
getSessionList(query: {
|
||||
page_no: number;
|
||||
page_size: number;
|
||||
title?: string;
|
||||
created_at?: string[];
|
||||
updated_at?: string[];
|
||||
}) {
|
||||
return request<ApiResponse<PageResult<ChatSession[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
createSession(body: { title: string }) {
|
||||
return request<ApiResponse<ChatSession>>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateSession(id: string, body: { title: string }) {
|
||||
return request<ApiResponse<ChatSession>>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteSession(body: string[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
chat(body: { message: string; session_id?: string | null }) {
|
||||
return request<ApiResponse<AiChatResponse>>({
|
||||
url: `${API_PATH}/ai-chat`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
getSessionDetail(sessionId: string) {
|
||||
return request<ApiResponse<ChatSessionDetail>>({
|
||||
url: `${API_PATH}/detail/${sessionId}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default AiChatAPI;
|
||||
|
||||
export interface ChatSessionMessage {
|
||||
id: string;
|
||||
role: string;
|
||||
content: string;
|
||||
created_at: number | null;
|
||||
}
|
||||
|
||||
export interface ChatSession {
|
||||
session_id: string;
|
||||
agent_id: string | null;
|
||||
team_id: string | null;
|
||||
team_name: string | null;
|
||||
workflow_id: string | null;
|
||||
user_id: string | null;
|
||||
session_data: Record<string, any> | null;
|
||||
agent_data: Record<string, any> | null;
|
||||
team_data: Record<string, any> | null;
|
||||
workflow_data: Record<string, any> | null;
|
||||
metadata: Record<string, any> | null;
|
||||
runs: Array<Record<string, any>> | null;
|
||||
summary: Record<string, any> | null;
|
||||
created_at: number | null;
|
||||
updated_at: number | null;
|
||||
|
||||
id: string;
|
||||
title: string | null;
|
||||
created_time: string | null;
|
||||
updated_time: string | null;
|
||||
message_count: number;
|
||||
messages: ChatSessionMessage[];
|
||||
}
|
||||
|
||||
export interface SessionGroup {
|
||||
id: string;
|
||||
title: string;
|
||||
sessions: ChatSession[];
|
||||
}
|
||||
|
||||
export interface UserInfo {
|
||||
id: number;
|
||||
name: string;
|
||||
username: string;
|
||||
avatar: string;
|
||||
email: string;
|
||||
}
|
||||
|
||||
export interface AiChatResponse {
|
||||
response: string;
|
||||
session_id: string;
|
||||
function_calls: Array<{
|
||||
name: string;
|
||||
arguments: Record<string, any>;
|
||||
}> | null;
|
||||
}
|
||||
|
||||
export interface ChatSessionDetail {
|
||||
session_id: string;
|
||||
agent_id: string | null;
|
||||
team_id: string | null;
|
||||
team_name: string | null;
|
||||
workflow_id: string | null;
|
||||
user_id: string | null;
|
||||
session_data: Record<string, any> | null;
|
||||
agent_data: Record<string, any> | null;
|
||||
team_data: Record<string, any> | null;
|
||||
workflow_data: Record<string, any> | null;
|
||||
metadata: Record<string, any> | null;
|
||||
runs: Array<Record<string, any>> | null;
|
||||
summary: Record<string, any> | null;
|
||||
created_at: number | null;
|
||||
updated_at: number | null;
|
||||
|
||||
id: string;
|
||||
title: string | null;
|
||||
created_time: string | null;
|
||||
updated_time: string | null;
|
||||
message_count: number;
|
||||
messages: ChatSessionMessage[];
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/application/portal";
|
||||
|
||||
export const ApplicationAPI = {
|
||||
/**
|
||||
* 获取应用详情
|
||||
* @param id 应用ID
|
||||
*/
|
||||
detailApp(id: number) {
|
||||
return request<ApiResponse<ApplicationInfo>>({
|
||||
url: `${API_PATH}/detail/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 查询应用列表
|
||||
* @param query 查询参数
|
||||
*/
|
||||
listApp(query: ApplicationPageQuery) {
|
||||
return request<ApiResponse<PageResult<ApplicationInfo[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建应用
|
||||
* @param body 应用信息
|
||||
*/
|
||||
createApp(body: ApplicationForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 修改应用
|
||||
* @param id 应用ID
|
||||
* @param body 应用信息
|
||||
*/
|
||||
updateApp(id: number, body: ApplicationForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除应用
|
||||
* @param body 应用ID数组
|
||||
*/
|
||||
deleteApp(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 批量修改应用状态
|
||||
* @param body 批量操作参数
|
||||
*/
|
||||
batchApp(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default ApplicationAPI;
|
||||
|
||||
/**
|
||||
* 应用分页查询参数
|
||||
*/
|
||||
export interface ApplicationPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
tenant_id?: number;
|
||||
status?: string;
|
||||
created_id?: number;
|
||||
created_time?: string[];
|
||||
updated_id?: number;
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用信息
|
||||
*/
|
||||
export interface ApplicationInfo extends BaseType {
|
||||
name?: string;
|
||||
access_url?: string;
|
||||
icon_url?: string;
|
||||
tenant?: TenantType;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用表单
|
||||
*/
|
||||
export interface ApplicationForm extends BaseFormType {
|
||||
name: string;
|
||||
access_url: string;
|
||||
icon_url: string;
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/example/demo";
|
||||
|
||||
const DemoAPI = {
|
||||
getDemoList(query: DemoPageQuery) {
|
||||
return request<ApiResponse<PageResult<DemoTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getDemoDetail(query: number) {
|
||||
return request<ApiResponse<DemoTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createDemo(body: DemoForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateDemo(id: number, body: DemoForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteDemo(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchDemo(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportDemo(body: DemoPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
downloadTemplateDemo() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/download/template`,
|
||||
method: "post",
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
importDemo(body: FormData) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/import`,
|
||||
method: "post",
|
||||
data: body,
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default DemoAPI;
|
||||
|
||||
export interface DemoPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface DemoTable extends BaseType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
a?: number;
|
||||
b?: number;
|
||||
c?: number;
|
||||
d?: boolean;
|
||||
e?: string;
|
||||
f?: string;
|
||||
g?: string;
|
||||
h?: string;
|
||||
i?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface DemoForm extends BaseFormType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
a?: number;
|
||||
b?: number;
|
||||
c?: number;
|
||||
d?: boolean;
|
||||
e?: string;
|
||||
f?: Date | string;
|
||||
g?: Date | string;
|
||||
h?: string;
|
||||
i?: Record<string, any>;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/example/demo01";
|
||||
|
||||
const Demo01API = {
|
||||
getDemo01List(query: Demo01PageQuery) {
|
||||
return request<ApiResponse<PageResult<Demo01Table[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getDemo01Detail(id: number) {
|
||||
return request<ApiResponse<Demo01Table>>({
|
||||
url: `${API_PATH}/detail/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createDemo01(body: Demo01Form) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateDemo01(id: number, body: Demo01Form) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteDemo01(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchDemo01(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportDemo01(body: Demo01PageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
downloadDemo01Template() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/download/template`,
|
||||
method: "post",
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
importDemo01(body: FormData) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/import`,
|
||||
method: "post",
|
||||
data: body,
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default Demo01API;
|
||||
|
||||
export interface Demo01PageQuery extends PageQuery {
|
||||
/** 与后端 Demo01QueryParam 一致 */
|
||||
name?: string;
|
||||
description?: string;
|
||||
/** 是否启用:0 启用 / 1 禁用(字符串) */
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 与后端 Demo01OutSchema 一致:
|
||||
* Demo01CreateSchema(name,status,description) + BaseSchema + UserBySchema
|
||||
*/
|
||||
export interface Demo01Table extends BaseType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
/** 与后端 Demo01CreateSchema / Demo01UpdateSchema 一致(不含 id,更新走 URL) */
|
||||
export interface Demo01Form extends BaseFormType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/generator/gencode";
|
||||
|
||||
const GencodeAPI = {
|
||||
// 查询生成表数据
|
||||
listTable(query: GenTablePageQuery) {
|
||||
return request<ApiResponse<PageResult<GenTableSchema[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
// 查询db数据库列表
|
||||
listDbTable(query: DBTablePageQuery) {
|
||||
return request<ApiResponse<PageResult<DBTableSchema[]>>>({
|
||||
url: `${API_PATH}/db/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
// 导入表
|
||||
importTable(table_names: string[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/import`,
|
||||
method: "post",
|
||||
data: table_names,
|
||||
});
|
||||
},
|
||||
|
||||
// 查询表详细信息
|
||||
detailTable(table_id: number) {
|
||||
return request<ApiResponse<GenTableSchema>>({
|
||||
url: `${API_PATH}/detail/${table_id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
// 创建表(与后端 GenCreateTableSqlBody 一致)
|
||||
createTable(sql: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: { sql },
|
||||
});
|
||||
},
|
||||
|
||||
// 更新表信息
|
||||
updateTable(data: GenTableSchema, table_id: number) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${table_id}`,
|
||||
method: "put",
|
||||
data,
|
||||
});
|
||||
},
|
||||
|
||||
// 删除表数据
|
||||
deleteTable(table_ids: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: table_ids,
|
||||
});
|
||||
},
|
||||
|
||||
// 批量生成代码
|
||||
batchGenCode(table_names: string[]) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/batch/output`,
|
||||
method: "patch",
|
||||
data: table_names,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
// 生成代码到指定路径
|
||||
genCodeToPath(table_name: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/output/${table_name}`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
// 预览生成代码
|
||||
previewTable(id: number) {
|
||||
return request<ApiResponse<Record<string, string>>>({
|
||||
url: `${API_PATH}/preview/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
// 同步数据库
|
||||
syncDb(table_name: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/sync_db/${table_name}`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
// 同步数据库差异预览(不落库)
|
||||
syncDbPreview(table_name: string) {
|
||||
return request<ApiResponse<GenSyncPreviewSchema>>({
|
||||
url: `${API_PATH}/sync_db/preview/${table_name}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default GencodeAPI;
|
||||
|
||||
/** 代码生成预览对象 */
|
||||
export interface GeneratorPreviewVO {
|
||||
/** 文件生成路径 */
|
||||
path: string;
|
||||
/** 文件名称 */
|
||||
file_name: string;
|
||||
/** 文件内容 */
|
||||
content: string;
|
||||
}
|
||||
|
||||
/** 业务表结构 */
|
||||
export interface GenTableSchema extends BaseType {
|
||||
table_name?: string;
|
||||
table_comment?: string;
|
||||
class_name?: string;
|
||||
package_name?: string;
|
||||
module_name?: string;
|
||||
business_name?: string;
|
||||
function_name?: string;
|
||||
description?: string;
|
||||
parent_menu_id?: number;
|
||||
sub?: boolean;
|
||||
sub_table_name?: string;
|
||||
sub_table_fk_name?: string;
|
||||
master_sub_hint?: string | null;
|
||||
pk_column?: GenTableColumnSchema;
|
||||
columns: GenTableColumnSchema[];
|
||||
sub_table?: GenTableSchema;
|
||||
}
|
||||
|
||||
export interface GenTableColumnSchema extends BaseType {
|
||||
table_id?: number;
|
||||
column_name?: string;
|
||||
column_comment?: string;
|
||||
column_type?: string;
|
||||
column_length?: string;
|
||||
column_default?: string;
|
||||
is_pk?: boolean;
|
||||
is_increment?: boolean;
|
||||
is_nullable?: boolean;
|
||||
is_unique?: boolean;
|
||||
sort?: number;
|
||||
python_type?: string;
|
||||
python_field?: string;
|
||||
html_type?: string | null;
|
||||
dict_type?: string;
|
||||
is_insert?: boolean | null;
|
||||
is_edit?: boolean | null;
|
||||
is_list?: boolean | null;
|
||||
is_query?: boolean | null;
|
||||
query_type?: string | null;
|
||||
}
|
||||
|
||||
/** 查询参数:生成表 */
|
||||
export interface GenTablePageQuery extends PageQuery {
|
||||
table_name?: string;
|
||||
table_comment?: string;
|
||||
}
|
||||
|
||||
/** 查询参数:DB 表 */
|
||||
export interface DBTablePageQuery extends PageQuery {
|
||||
table_name?: string;
|
||||
table_comment?: string;
|
||||
}
|
||||
|
||||
export interface DBTableSchema {
|
||||
table_name: string;
|
||||
table_comment?: string;
|
||||
create_time?: string;
|
||||
update_time?: string;
|
||||
}
|
||||
|
||||
export interface GenSyncColumnChange {
|
||||
column_name: string;
|
||||
before?: Record<string, any> | null;
|
||||
after?: Record<string, any> | null;
|
||||
changed_keys?: string[];
|
||||
}
|
||||
|
||||
export interface GenSyncPreviewSchema {
|
||||
table_name: string;
|
||||
added: string[];
|
||||
removed: string[];
|
||||
unchanged: string[];
|
||||
changed: GenSyncColumnChange[];
|
||||
sub_tables?: GenSyncPreviewSchema[];
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/monitor/cache";
|
||||
|
||||
const CacheAPI = {
|
||||
getCacheInfo() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/info`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
getCacheNames() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/get/names`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
getCacheKeys(cacheName: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/get/keys/${cacheName}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
getCacheValue(cacheName: string, cacheKey: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/get/value/${cacheName}/${cacheKey}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
deleteCacheName(cacheName: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete/name/${cacheName}`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
deleteCacheKey(cacheKey: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete/key/${cacheKey}`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
deleteCacheAll() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete/all`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default CacheAPI;
|
||||
|
||||
export interface CacheForm {
|
||||
cache_name: string;
|
||||
cache_key: string;
|
||||
cache_value: string;
|
||||
}
|
||||
|
||||
export interface CacheInfo {
|
||||
cache_key: string;
|
||||
cache_name: string;
|
||||
cache_value: string;
|
||||
remark: string;
|
||||
}
|
||||
|
||||
export interface CommandStats {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface RedisInfo {
|
||||
redis_version: string;
|
||||
redis_mode: string;
|
||||
tcp_port: number;
|
||||
connected_clients: number;
|
||||
uptime_in_days: number;
|
||||
used_memory_human: string;
|
||||
used_cpu_user_children: string;
|
||||
maxmemory_human: string;
|
||||
aof_enabled: string;
|
||||
rdb_last_bgsave_status: string;
|
||||
instantaneous_input_kbps: number;
|
||||
instantaneous_output_kbps: number;
|
||||
}
|
||||
|
||||
export interface CacheMonitor {
|
||||
command_stats: CommandStats[];
|
||||
db_size: number;
|
||||
info: RedisInfo;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/monitor/online";
|
||||
|
||||
const OnlineAPI = {
|
||||
// 查询在线用户列表
|
||||
listOnline(query: OnlineUserPageQuery) {
|
||||
return request<ApiResponse<PageResult<OnlineUserTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
// 强退用户
|
||||
deleteOnline(body: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
// 强退用户
|
||||
clearOnline() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/clear`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default OnlineAPI;
|
||||
|
||||
export interface OnlineUserPageQuery extends PageQuery {
|
||||
ipaddr?: string;
|
||||
name?: string;
|
||||
login_location?: string;
|
||||
}
|
||||
|
||||
export interface OnlineUserTable {
|
||||
session_id: string;
|
||||
user_id: number;
|
||||
name: string;
|
||||
user_name: string;
|
||||
ipaddr: string;
|
||||
login_location: string;
|
||||
os: string;
|
||||
browser: string;
|
||||
login_time: string;
|
||||
login_type: string;
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/monitor/resource";
|
||||
|
||||
export const ResourceAPI = {
|
||||
/**
|
||||
* 获取目录列表
|
||||
* @param query 查询参数
|
||||
*/
|
||||
listResource(query: ResourcePageQuery) {
|
||||
return request<ApiResponse<PageResult<ResourceItem[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param formData 文件数据
|
||||
*/
|
||||
uploadFile(formData: FormData) {
|
||||
return request<ApiResponse<ResourceUploadSchema>>({
|
||||
url: `${API_PATH}/upload`,
|
||||
method: "post",
|
||||
data: formData,
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
* @param path 文件路径
|
||||
*/
|
||||
downloadFile(path: string) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/download`,
|
||||
method: "get",
|
||||
params: { path },
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 删除文件或目录
|
||||
* @param body 文件路径数组
|
||||
*/
|
||||
deleteResource(body: string[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 移动文件或目录
|
||||
* @param body 移动参数
|
||||
*/
|
||||
moveResource(body: ResourceMoveQuery) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/move`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 复制文件或目录
|
||||
* @param body 复制参数
|
||||
*/
|
||||
copyResource(body: ResourceCopyQuery) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/copy`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 重命名文件或目录
|
||||
* @param body 重命名参数
|
||||
*/
|
||||
renameResource(body: ResourceRenameQuery) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/rename`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 创建目录
|
||||
* @param body 创建目录参数
|
||||
*/
|
||||
createDirectory(body: ResourceCreateDirQuery) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create-dir`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 导出资源列表
|
||||
* @param body 导出条件
|
||||
*/
|
||||
exportResource(body: ResourcePageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default ResourceAPI;
|
||||
|
||||
/**
|
||||
* 资源列表查询参数
|
||||
*/
|
||||
export interface ResourceListQuery {
|
||||
/** 目录路径 */
|
||||
path?: string;
|
||||
/** 包含隐藏文件 */
|
||||
include_hidden?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源目录模型
|
||||
*/
|
||||
export interface ResourceDirectorySchema {
|
||||
/** 目录路径 */
|
||||
path: string;
|
||||
/** 目录名称 */
|
||||
name: string;
|
||||
/** 目录项 */
|
||||
items: ResourceItem[];
|
||||
/** 文件总数 */
|
||||
total_files: number;
|
||||
/** 目录总数 */
|
||||
total_dirs: number;
|
||||
/** 总大小 */
|
||||
total_size: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源搜索查询参数
|
||||
*/
|
||||
export interface ResourceSearchQuery {
|
||||
/** 关键词 */
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源分页查询参数
|
||||
*/
|
||||
export interface ResourcePageQuery extends PageQuery {
|
||||
/** 关键词 */
|
||||
name?: string;
|
||||
/** 目录路径 */
|
||||
path?: string;
|
||||
/** 包含隐藏文件 */
|
||||
include_hidden?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源上传响应模型
|
||||
*/
|
||||
export interface ResourceUploadSchema {
|
||||
/** 文件名 */
|
||||
filename: string;
|
||||
/** 访问URL */
|
||||
file_url: string;
|
||||
/** 文件大小 */
|
||||
file_size: number;
|
||||
/** 上传时间 */
|
||||
upload_time: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源项信息
|
||||
*/
|
||||
export interface ResourceItem {
|
||||
/** 文件/目录名称 */
|
||||
name: string;
|
||||
/** 文件URL路径 */
|
||||
file_url: string;
|
||||
/** 相对路径 */
|
||||
relative_path?: string;
|
||||
/** 是否为文件 */
|
||||
is_file?: boolean;
|
||||
/** 是否为目录 */
|
||||
is_dir?: boolean;
|
||||
/** 文件大小(字节) */
|
||||
size?: number | null;
|
||||
/** 创建时间 */
|
||||
created_time: string;
|
||||
/** 修改时间 */
|
||||
modified_time: string;
|
||||
/** 是否为隐藏文件 */
|
||||
is_hidden?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源移动参数
|
||||
*/
|
||||
export interface ResourceMoveQuery {
|
||||
/** 源路径 */
|
||||
source_path: string;
|
||||
/** 目标路径 */
|
||||
target_path: string;
|
||||
/** 是否覆盖 */
|
||||
overwrite?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源复制参数
|
||||
*/
|
||||
export interface ResourceCopyQuery {
|
||||
/** 源路径 */
|
||||
source_path: string;
|
||||
/** 目标路径 */
|
||||
target_path: string;
|
||||
/** 是否覆盖 */
|
||||
overwrite?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源重命名参数
|
||||
*/
|
||||
export interface ResourceRenameQuery {
|
||||
/** 原路径 */
|
||||
old_path: string;
|
||||
/** 新名称 */
|
||||
new_name: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建目录参数
|
||||
*/
|
||||
export interface ResourceCreateDirQuery {
|
||||
/** 父目录路径 */
|
||||
parent_path: string;
|
||||
/** 目录名称 */
|
||||
dir_name: string;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/monitor/server";
|
||||
|
||||
const ServerAPI = {
|
||||
// 获取服务信息
|
||||
getServer() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/info`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default ServerAPI;
|
||||
|
||||
export interface Cpu {
|
||||
cpu_num: number;
|
||||
used: number;
|
||||
sys: number;
|
||||
free: number;
|
||||
}
|
||||
|
||||
export interface Memory {
|
||||
total: string;
|
||||
used: string;
|
||||
free: string;
|
||||
usage: number;
|
||||
}
|
||||
|
||||
export interface System {
|
||||
computer_name: string;
|
||||
os_name: string;
|
||||
computer_ip: string;
|
||||
os_arch: string;
|
||||
user_dir: string;
|
||||
}
|
||||
|
||||
export interface Python {
|
||||
name: string;
|
||||
version: string;
|
||||
start_time: string;
|
||||
run_time: string;
|
||||
home: string;
|
||||
memory_total: string;
|
||||
memory_used: string;
|
||||
memory_free: string;
|
||||
memory_usage: number;
|
||||
}
|
||||
|
||||
export interface SysFile {
|
||||
dirName: string;
|
||||
sysTypeName: string;
|
||||
typeName: string;
|
||||
total: string;
|
||||
free: string;
|
||||
used: string;
|
||||
usage: number;
|
||||
}
|
||||
|
||||
export interface ServerInfo {
|
||||
cpu: Cpu;
|
||||
mem: Memory;
|
||||
sys: System;
|
||||
py: Python;
|
||||
disks: SysFile[];
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import request from "@/utils/http";
|
||||
// import request from '@/utils/http'
|
||||
|
||||
const API_PATH = "/system/auth";
|
||||
|
||||
/** 第三方 OAuth 登录渠道(与后端 `/system/auth/oauth/{provider}` 一致) */
|
||||
export type OAuthProvider = "wechat" | "qq" | "github" | "gitee";
|
||||
|
||||
const AuthAPI = {
|
||||
/**
|
||||
* 登录
|
||||
* @param body 登录参数
|
||||
* @returns 登录响应
|
||||
*/
|
||||
login(body: LoginFormData) {
|
||||
return request<ApiResponse<LoginResult>>({
|
||||
url: `${API_PATH}/login`,
|
||||
method: "post",
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
},
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
refreshToken(body: RefreshToekenBody) {
|
||||
return request<ApiResponse<LoginResult>>({
|
||||
url: `${API_PATH}/token/refresh`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
getCaptcha() {
|
||||
return request<ApiResponse<CaptchaInfo>>({
|
||||
url: `${API_PATH}/captcha/get`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
logout(body: LogoutBody) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/logout`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 获取免登录用户列表 */
|
||||
getAutoLoginUsers() {
|
||||
return request<ApiResponse<AutoLoginUser[]>>({
|
||||
url: `${API_PATH}/auto-login/users`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 获取免登录Token */
|
||||
getAutoLoginToken(userId: number) {
|
||||
return request<ApiResponse<AutoLoginToken>>({
|
||||
url: `${API_PATH}/auto-login/token`,
|
||||
method: "post",
|
||||
params: { user_id: userId },
|
||||
});
|
||||
},
|
||||
|
||||
/** 免登录 */
|
||||
autoLogin(token: string) {
|
||||
return request<ApiResponse<LoginResult>>({
|
||||
url: `${API_PATH}/auto-login`,
|
||||
method: "post",
|
||||
params: { token },
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default AuthAPI;
|
||||
|
||||
/** 登录表单数据 */
|
||||
export interface LoginFormData {
|
||||
username: string;
|
||||
password: string;
|
||||
captcha_key: string;
|
||||
captcha: string;
|
||||
remember: boolean;
|
||||
login_type: string;
|
||||
}
|
||||
|
||||
// 刷新令牌
|
||||
export interface RefreshToekenBody {
|
||||
refresh_token: string;
|
||||
}
|
||||
|
||||
/** 登录响应 */
|
||||
export interface LoginResult {
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
token_type: string;
|
||||
expires_in: number;
|
||||
}
|
||||
|
||||
/** 验证码信息 */
|
||||
export interface CaptchaInfo {
|
||||
enable: boolean;
|
||||
key: string;
|
||||
img_base: string;
|
||||
}
|
||||
|
||||
/** 退出登录操作 */
|
||||
export interface LogoutBody {
|
||||
token: string;
|
||||
}
|
||||
|
||||
/** 免登录用户信息 */
|
||||
export interface AutoLoginUser {
|
||||
id: number;
|
||||
username: string;
|
||||
name: string;
|
||||
avatar: string | null;
|
||||
}
|
||||
|
||||
/** 免登录Token响应 */
|
||||
export interface AutoLoginToken {
|
||||
token: string;
|
||||
user: AutoLoginUser;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/dept";
|
||||
|
||||
const DeptAPI = {
|
||||
listDept(query?: DeptPageQuery) {
|
||||
return request<ApiResponse<DeptTable[]>>({
|
||||
url: `${API_PATH}/tree`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailDept(query: number) {
|
||||
return request<ApiResponse<DeptTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createDept(body: DeptForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateDept(id: number, body: DeptForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteDept(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchDept(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default DeptAPI;
|
||||
|
||||
export interface DeptPageQuery {
|
||||
name?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
}
|
||||
|
||||
export interface DeptTable extends BaseType {
|
||||
name?: string;
|
||||
order?: number;
|
||||
code: string;
|
||||
leader?: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
parent_id?: number;
|
||||
parent_name?: string;
|
||||
children?: DeptTable[];
|
||||
}
|
||||
|
||||
export interface DeptForm extends BaseFormType {
|
||||
name?: string;
|
||||
order?: number;
|
||||
code: string;
|
||||
leader?: string;
|
||||
phone?: string;
|
||||
email?: string;
|
||||
parent_id?: number;
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/dict";
|
||||
|
||||
const DictAPI = {
|
||||
listDictType(query: DictPageQuery) {
|
||||
return request<ApiResponse<PageResult<DictTable[]>>>({
|
||||
url: `${API_PATH}/type/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
optionDictType() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/type/optionselect`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
detailDictType(query: number) {
|
||||
return request<ApiResponse<DictTable>>({
|
||||
url: `${API_PATH}/type/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createDictType(body: DictForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/type/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateDictType(id: number, body: DictForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/type/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteDictType(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/type/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchDictType(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/type/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportDictType(body: DictPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/type/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
listDictData(query: DictDataPageQuery) {
|
||||
return request<ApiResponse<PageResult<DictDataTable[]>>>({
|
||||
url: `${API_PATH}/data/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailDictData(query: number) {
|
||||
return request<ApiResponse<DictDataTable>>({
|
||||
url: `${API_PATH}/data/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createDictData(body: DictDataForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/data/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateDictData(id: number, body: DictDataForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/data/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteDictData(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/data/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchDictData(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/data/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportDictData(body: DictDataPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/data/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
getInitDict(dict_type: string) {
|
||||
return request<ApiResponse<DictDataTable[]>>({
|
||||
url: `${API_PATH}/data/info/${dict_type}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default DictAPI;
|
||||
|
||||
export interface DictPageQuery extends PageQuery {
|
||||
dict_name?: string;
|
||||
dict_type?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
export interface DictDataPageQuery extends PageQuery {
|
||||
dict_label?: string;
|
||||
dict_type?: string;
|
||||
dict_type_id?: number;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
export interface DictTable extends BaseType {
|
||||
dict_name?: string;
|
||||
dict_type?: string;
|
||||
}
|
||||
|
||||
export interface DictForm extends BaseFormType {
|
||||
dict_name?: string;
|
||||
dict_type?: string;
|
||||
}
|
||||
|
||||
export interface DictDataTable extends BaseType {
|
||||
dict_sort?: number;
|
||||
dict_label?: string;
|
||||
dict_value?: string;
|
||||
dict_type_id?: number;
|
||||
dict_type?: string;
|
||||
css_class?: string;
|
||||
list_class?: string;
|
||||
is_default?: boolean;
|
||||
}
|
||||
|
||||
export interface DictDataForm extends BaseFormType {
|
||||
dict_sort?: number;
|
||||
dict_label?: string;
|
||||
dict_value?: string;
|
||||
dict_type_id?: number;
|
||||
dict_type?: string;
|
||||
css_class?: string;
|
||||
list_class?: string;
|
||||
is_default?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/log";
|
||||
|
||||
const LogAPI = {
|
||||
listLog(query: LogPageQuery) {
|
||||
return request<ApiResponse<PageResult<LogTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailLog(query: number) {
|
||||
return request<ApiResponse<LogTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
deleteLog(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportLog(body: LogPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default LogAPI;
|
||||
|
||||
export interface LogPageQuery extends PageQuery {
|
||||
type?: number;
|
||||
request_path?: string;
|
||||
creator_name?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface LogTable extends BaseType {
|
||||
type?: number; // 1 登录日志 2 操作日志
|
||||
request_path?: string;
|
||||
request_method?: string;
|
||||
request_ip?: string;
|
||||
login_location?: string;
|
||||
request_browser?: string;
|
||||
request_os?: string;
|
||||
response_code?: number;
|
||||
request_payload?: string;
|
||||
response_json?: string;
|
||||
process_time?: string;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/menu";
|
||||
|
||||
const MenuAPI = {
|
||||
listMenu(query?: MenuPageQuery) {
|
||||
return request<ApiResponse<MenuTable[]>>({
|
||||
url: `${API_PATH}/tree`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailMenu(query: number) {
|
||||
return request<ApiResponse<MenuTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createMenu(body: MenuForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateMenu(id: number, body: MenuForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteMenu(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchMenu(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default MenuAPI;
|
||||
|
||||
export interface MenuPageQuery {
|
||||
name?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
/** 与后端 Query `menu_client` 一致:pc | app;菜单管理 Tab 切换时传入 */
|
||||
menu_client?: "pc" | "app";
|
||||
}
|
||||
|
||||
export interface MenuTable extends BaseType {
|
||||
name?: string;
|
||||
type?: number;
|
||||
icon?: string;
|
||||
order?: number;
|
||||
permission?: string;
|
||||
route_name?: string;
|
||||
route_path?: string;
|
||||
component_path?: string;
|
||||
redirect?: string;
|
||||
parent_id?: number;
|
||||
parent_name?: string;
|
||||
keep_alive?: boolean;
|
||||
hidden?: boolean;
|
||||
always_show?: boolean;
|
||||
title?: string;
|
||||
params?: { key: string; value: string }[];
|
||||
affix?: boolean;
|
||||
children?: MenuTable[];
|
||||
client?: "pc" | "app";
|
||||
}
|
||||
|
||||
export interface MenuForm extends BaseFormType {
|
||||
name?: string;
|
||||
type?: number;
|
||||
icon?: string;
|
||||
order?: number;
|
||||
permission?: string;
|
||||
route_name?: string;
|
||||
route_path?: string;
|
||||
component_path?: string;
|
||||
redirect?: string;
|
||||
parent_id?: number;
|
||||
keep_alive?: boolean;
|
||||
hidden?: boolean;
|
||||
always_show?: boolean;
|
||||
title?: string;
|
||||
params?: KeyValue[];
|
||||
affix?: boolean;
|
||||
client?: "pc" | "app";
|
||||
}
|
||||
|
||||
export interface KeyValue {
|
||||
key: string;
|
||||
value: string;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/notice";
|
||||
|
||||
const NoticeAPI = {
|
||||
listNotice(query: NoticePageQuery) {
|
||||
return request<ApiResponse<PageResult<NoticeTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
listNoticeAvailable() {
|
||||
return request<ApiResponse<PageResult<NoticeTable[]>>>({
|
||||
url: `${API_PATH}/available`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
detailNotice(query: number) {
|
||||
return request<ApiResponse<NoticeTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createNotice(body: NoticeForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateNotice(id: number, body: NoticeForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteNotice(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchNotice(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportNotice(body: NoticePageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default NoticeAPI;
|
||||
|
||||
export interface NoticePageQuery extends PageQuery {
|
||||
notice_title?: string;
|
||||
notice_type?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface NoticeTable extends BaseType {
|
||||
notice_title?: string;
|
||||
notice_type?: string;
|
||||
notice_content?: string;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
export interface NoticeForm extends BaseFormType {
|
||||
notice_title?: string;
|
||||
notice_type?: string;
|
||||
notice_content?: string;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import request from "@/utils/http";
|
||||
import { NO_AUTH_FLAG } from "@/utils/http/config";
|
||||
|
||||
const API_PATH = "/system/param";
|
||||
|
||||
const ParamsAPI = {
|
||||
uploadFile(body: any) {
|
||||
return request<ApiResponse<UploadFilePath>>({
|
||||
url: `${API_PATH}/upload`,
|
||||
method: "post",
|
||||
data: body,
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
},
|
||||
|
||||
/** 登录前拉取站点参数:不带 Token,避免过期 JWT 导致 401 无法展示底部备案等 */
|
||||
getInitConfig() {
|
||||
return request<ApiResponse<ConfigTable[]>>({
|
||||
url: `${API_PATH}/info`,
|
||||
method: "get",
|
||||
headers: {
|
||||
Authorization: NO_AUTH_FLAG,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
listParams(query: ConfigPageQuery) {
|
||||
return request<ApiResponse<PageResult<ConfigTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailParams(query: number) {
|
||||
return request<ApiResponse<ConfigTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createParams(body: ConfigForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateParams(id: number, body: ConfigForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteParams(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportParams(body: ConfigPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default ParamsAPI;
|
||||
|
||||
export interface ConfigPageQuery extends PageQuery {
|
||||
config_name?: string;
|
||||
config_key?: string;
|
||||
config_type?: boolean;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
export interface ConfigTable extends BaseType {
|
||||
config_name?: string;
|
||||
config_key?: string;
|
||||
config_value?: string;
|
||||
config_type?: boolean;
|
||||
}
|
||||
|
||||
export interface ConfigForm extends BaseFormType {
|
||||
config_name?: string;
|
||||
config_key?: string;
|
||||
config_value?: string;
|
||||
config_type?: boolean;
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/position";
|
||||
|
||||
const PositionAPI = {
|
||||
listPosition(query?: PositionPageQuery) {
|
||||
return request<ApiResponse<PageResult<PositionTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailPosition(query: number) {
|
||||
return request<ApiResponse<PositionTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createPosition(body: PositionForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updatePosition(id: number, body: PositionForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deletePosition(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchPosition(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportPosition(body: PositionPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default PositionAPI;
|
||||
|
||||
export interface PositionPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
status?: string;
|
||||
created_id?: number;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
export interface PositionTable extends BaseType {
|
||||
name?: string;
|
||||
order?: number;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
export interface PositionForm extends BaseFormType {
|
||||
name?: string;
|
||||
order?: number;
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/role";
|
||||
|
||||
const RoleAPI = {
|
||||
listRole(query?: TablePageQuery) {
|
||||
return request<ApiResponse<PageResult<RoleTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailRole(query: number) {
|
||||
return request<ApiResponse<RoleTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createRole(body: RoleForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateRole(id: number, body: RoleForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteRole(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchRole(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
setPermission(body: permissionDataType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/permission/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportRole(body: TablePageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default RoleAPI;
|
||||
|
||||
export interface TablePageQuery extends PageQuery {
|
||||
name?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
export interface RoleTable extends BaseType {
|
||||
id: number;
|
||||
name: string;
|
||||
order?: number;
|
||||
code: string;
|
||||
data_scope?: number;
|
||||
menus?: permissionMenuType[];
|
||||
depts?: permissionDeptType[];
|
||||
}
|
||||
|
||||
export interface RoleForm extends BaseFormType {
|
||||
name?: string;
|
||||
order?: number;
|
||||
code: string;
|
||||
}
|
||||
|
||||
export interface permissionDataType {
|
||||
data_scope: number;
|
||||
role_ids: RoleTable["id"][];
|
||||
menu_ids: permissionMenuType["id"][];
|
||||
dept_ids: permissionDeptType["id"][];
|
||||
}
|
||||
|
||||
export interface permissionDeptType {
|
||||
id: number;
|
||||
name: string;
|
||||
parent_id: number;
|
||||
children: permissionDeptType[];
|
||||
}
|
||||
|
||||
export interface permissionMenuType {
|
||||
id: number;
|
||||
name: string;
|
||||
type: number;
|
||||
permission: string;
|
||||
parent_id?: number;
|
||||
status: string;
|
||||
description?: string;
|
||||
children?: permissionMenuType[];
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/system/tenant";
|
||||
|
||||
const TenantAPI = {
|
||||
listTenant(query?: TenantPageQuery) {
|
||||
return request<ApiResponse<PageResult<TenantTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailTenant(id: number) {
|
||||
return request<ApiResponse<TenantTable>>({
|
||||
url: `${API_PATH}/detail/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createTenant(body: TenantCreateForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateTenant(id: number, body: TenantUpdateForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteTenant(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
batchTenant(body: BatchType) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default TenantAPI;
|
||||
|
||||
export interface TenantPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
}
|
||||
|
||||
export interface TenantTable extends BaseType {
|
||||
name: string;
|
||||
code: string;
|
||||
start_time?: string;
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
export interface TenantForm {
|
||||
id?: number;
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
start_time?: string;
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
export interface TenantCreateForm {
|
||||
name: string;
|
||||
code: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
start_time?: string;
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
export interface TenantUpdateForm {
|
||||
name?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
start_time?: string;
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
export interface BatchType {
|
||||
ids: number[];
|
||||
status: string;
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
import request from "@/utils/http";
|
||||
import { MenuTable, MenuForm } from "@/api/module_system/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: `${API_PATH}/current/avatar/upload`,
|
||||
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(body: ResetPasswordForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/reset/password`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
registerUser(body: RegisterForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/register`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
forgetPassword(body: ForgetPasswordForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/forget/password`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
listUser(query: UserPageQuery) {
|
||||
return request<ApiResponse<PageResult<UserInfo[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailUser(query: number) {
|
||||
return request<ApiResponse<UserInfo>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
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}/available/setting`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
exportUser(body: UserPageQuery) {
|
||||
return request<Blob>({
|
||||
url: `${API_PATH}/export`,
|
||||
method: "post",
|
||||
data: body,
|
||||
responseType: "blob",
|
||||
});
|
||||
},
|
||||
|
||||
downloadTemplateUser() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/import/template`,
|
||||
method: "post",
|
||||
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 {
|
||||
username: string;
|
||||
new_password: string;
|
||||
mobile?: string;
|
||||
confirmPassword: string;
|
||||
}
|
||||
|
||||
export interface RegisterForm {
|
||||
username: string;
|
||||
password: string;
|
||||
confirmPassword: string;
|
||||
}
|
||||
|
||||
export interface UserPageQuery extends PageQuery {
|
||||
username?: string;
|
||||
name?: string;
|
||||
mobile?: string;
|
||||
email?: string;
|
||||
dept_id?: number;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface searchSelectDataType {
|
||||
name?: string;
|
||||
status?: string;
|
||||
}
|
||||
|
||||
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;
|
||||
last_login?: string;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
export interface deptTreeType {
|
||||
id?: number;
|
||||
name?: string;
|
||||
parent_id?: number;
|
||||
children?: deptTreeType[];
|
||||
}
|
||||
|
||||
export interface roleSelectorType {
|
||||
id?: number;
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
menus?: MenuForm[];
|
||||
}
|
||||
|
||||
export interface positionSelectorType {
|
||||
id?: number;
|
||||
name?: string;
|
||||
status?: string;
|
||||
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;
|
||||
}
|
||||
|
||||
export interface PasswordFormState {
|
||||
old_password: string;
|
||||
new_password: string;
|
||||
confirm_password: string;
|
||||
}
|
||||
|
||||
export interface ResetPasswordForm {
|
||||
id: number;
|
||||
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;
|
||||
}
|
||||
|
||||
export interface CurrentUserFormState {
|
||||
name?: string;
|
||||
gender?: number;
|
||||
mobile?: string;
|
||||
email?: string;
|
||||
avatar?: string;
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/task/cronjob/job";
|
||||
|
||||
const JobAPI = {
|
||||
getSchedulerStatus() {
|
||||
return request<ApiResponse<SchedulerStatus>>({
|
||||
url: `${API_PATH}/scheduler/status`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
getSchedulerJobs() {
|
||||
return request<ApiResponse<SchedulerJob[]>>({
|
||||
url: `${API_PATH}/scheduler/jobs`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
startScheduler() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/scheduler/start`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
pauseScheduler() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/scheduler/pause`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
resumeScheduler() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/scheduler/resume`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
shutdownScheduler() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/scheduler/shutdown`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
clearAllJobs() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/scheduler/jobs/clear`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
getSchedulerConsole() {
|
||||
return request<ApiResponse<string>>({
|
||||
url: `${API_PATH}/scheduler/console`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
syncJobsToDb() {
|
||||
return request<ApiResponse<number>>({
|
||||
url: `${API_PATH}/scheduler/sync`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
pauseJob(jobId: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/task/pause/${jobId}`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
resumeJob(jobId: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/task/resume/${jobId}`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
runJobNow(jobId: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/task/run/${jobId}`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
removeJob(jobId: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/task/remove/${jobId}`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
getJobLogList(query: JobLogPageQuery) {
|
||||
return request<ApiResponse<PageResult<JobLogTable[]>>>({
|
||||
url: `${API_PATH}/log/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getJobLogDetail(id: number) {
|
||||
return request<ApiResponse<JobLogTable>>({
|
||||
url: `${API_PATH}/log/detail/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
deleteJobLog(ids: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/log/delete`,
|
||||
method: "delete",
|
||||
data: ids,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default JobAPI;
|
||||
|
||||
export interface SchedulerStatus {
|
||||
status: string;
|
||||
is_running: boolean;
|
||||
job_count: number;
|
||||
}
|
||||
|
||||
export interface SchedulerJob {
|
||||
id: string;
|
||||
name: string;
|
||||
trigger: string;
|
||||
next_run_time?: string;
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface JobLogPageQuery extends PageQuery {
|
||||
job_id?: string;
|
||||
job_name?: string;
|
||||
status?: string;
|
||||
trigger_type?: string;
|
||||
}
|
||||
|
||||
export interface JobLogTable extends BaseType {
|
||||
job_id: string;
|
||||
job_name?: string;
|
||||
trigger_type?: string;
|
||||
status: string;
|
||||
next_run_time?: string;
|
||||
job_state?: string;
|
||||
result?: string;
|
||||
error?: string;
|
||||
created_time?: string;
|
||||
updated_time?: string;
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
const API_PATH = "/task/cronjob/node";
|
||||
|
||||
const NodeAPI = {
|
||||
getNodeTypeOptions() {
|
||||
return request<ApiResponse<NodeType[]>>({
|
||||
url: `${API_PATH}/options`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
listNode(query: NodePageQuery) {
|
||||
return request<ApiResponse<PageResult<NodeTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
detailNode(query: number) {
|
||||
return request<ApiResponse<NodeTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createNode(body: NodeForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateNode(id: number, body: NodeForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteNode(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
clearNode() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/clear`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
executeNode(id: number, params: ExecuteNodeParams = { trigger: "now" }) {
|
||||
return request<ApiResponse<ExecuteNodeResult>>({
|
||||
url: `${API_PATH}/execute/${id}`,
|
||||
method: "post",
|
||||
data: params,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default NodeAPI;
|
||||
|
||||
export interface NodePageQuery extends PageQuery {
|
||||
name?: string;
|
||||
code?: string;
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
}
|
||||
|
||||
export type TriggerType = "now" | "cron" | "interval" | "date";
|
||||
|
||||
export interface ExecuteNodeParams {
|
||||
trigger: TriggerType;
|
||||
trigger_args?: string;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
export interface ExecuteNodeResult {
|
||||
job_id: number;
|
||||
status: string;
|
||||
trigger: TriggerType;
|
||||
}
|
||||
|
||||
export interface NodeTable extends BaseType {
|
||||
name: string;
|
||||
code: string;
|
||||
jobstore?: string;
|
||||
executor?: string;
|
||||
trigger?: TriggerType;
|
||||
trigger_args?: string;
|
||||
func?: string;
|
||||
args?: string;
|
||||
kwargs?: string;
|
||||
coalesce?: boolean;
|
||||
max_instances?: number;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
export interface NodeForm {
|
||||
id?: number;
|
||||
name: string;
|
||||
code?: string;
|
||||
jobstore?: string;
|
||||
executor?: string;
|
||||
func?: string;
|
||||
args?: string;
|
||||
kwargs?: string;
|
||||
coalesce?: boolean;
|
||||
max_instances?: number;
|
||||
start_date?: string;
|
||||
end_date?: string;
|
||||
}
|
||||
|
||||
export interface NodeType {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
func?: string;
|
||||
args?: string;
|
||||
kwargs?: string;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
/** 对应后端 `plugin.module_task.workflow.definition` */
|
||||
const API_PATH = "/task/workflow/definition";
|
||||
|
||||
const WorkflowDefinitionAPI = {
|
||||
getWorkflowList(query: WorkflowPageQuery) {
|
||||
return request<ApiResponse<PageResult<WorkflowTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getWorkflowDetail(query: number) {
|
||||
return request<ApiResponse<WorkflowTable>>({
|
||||
url: `${API_PATH}/detail/${query}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createWorkflow(body: WorkflowForm) {
|
||||
return request<ApiResponse<WorkflowTable>>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateWorkflow(id: number, body: WorkflowForm) {
|
||||
return request<ApiResponse<WorkflowTable>>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteWorkflow(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
publishWorkflow(id: number, body: WorkflowPublishForm) {
|
||||
return request<ApiResponse<WorkflowTable>>({
|
||||
url: `${API_PATH}/publish/${id}`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
executeWorkflow(body: WorkflowExecuteForm) {
|
||||
return request<ApiResponse<WorkflowExecuteResult>>({
|
||||
url: `${API_PATH}/execute`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default WorkflowDefinitionAPI;
|
||||
export { WorkflowDefinitionAPI };
|
||||
|
||||
export interface WorkflowPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface WorkflowTable extends BaseType {
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
nodes?: any[];
|
||||
edges?: any[];
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
export interface WorkflowForm extends BaseFormType {
|
||||
name?: string;
|
||||
code?: string;
|
||||
status?: string;
|
||||
description?: string;
|
||||
nodes?: any[];
|
||||
edges?: any[];
|
||||
}
|
||||
|
||||
export interface WorkflowPublishForm {
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
export interface WorkflowExecuteForm {
|
||||
workflow_id: number;
|
||||
variables?: Record<string, any>;
|
||||
business_key?: string;
|
||||
job_id?: number;
|
||||
}
|
||||
|
||||
export interface WorkflowExecuteResult {
|
||||
workflow_id: number;
|
||||
workflow_name: string;
|
||||
status: string;
|
||||
start_time?: string;
|
||||
end_time?: string;
|
||||
variables?: Record<string, any>;
|
||||
node_results?: Record<string, any>;
|
||||
error?: string;
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import request from "@/utils/http";
|
||||
|
||||
/** 对应后端 `plugin.module_task.workflow.node_type` */
|
||||
const API_PATH = "/task/workflow/node-type";
|
||||
|
||||
const WorkflowNodeTypeAPI = {
|
||||
getWorkflowNodeTypeOptions() {
|
||||
return request<ApiResponse<WorkflowNodeTypeOption[]>>({
|
||||
url: `${API_PATH}/options`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
getWorkflowNodeTypeList(query: WorkflowNodeTypePageQuery) {
|
||||
return request<ApiResponse<PageResult<WorkflowNodeTypeTable[]>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
getWorkflowNodeTypeDetail(id: number) {
|
||||
return request<ApiResponse<WorkflowNodeTypeTable>>({
|
||||
url: `${API_PATH}/detail/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createWorkflowNodeType(body: WorkflowNodeTypeForm) {
|
||||
return request<ApiResponse<WorkflowNodeTypeTable>>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
updateWorkflowNodeType(id: number, body: WorkflowNodeTypeForm) {
|
||||
return request<ApiResponse<WorkflowNodeTypeTable>>({
|
||||
url: `${API_PATH}/update/${id}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
deleteWorkflowNodeType(body: number[]) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete`,
|
||||
method: "delete",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default WorkflowNodeTypeAPI;
|
||||
export { WorkflowNodeTypeAPI };
|
||||
|
||||
/** 编排节点类型选项(对应后端 task_workflow_node_type) */
|
||||
export interface WorkflowNodeTypeOption {
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
category: string;
|
||||
args?: string;
|
||||
kwargs?: string;
|
||||
}
|
||||
|
||||
export interface WorkflowNodeTypePageQuery extends PageQuery {
|
||||
name?: string;
|
||||
code?: string;
|
||||
category?: string;
|
||||
is_active?: boolean;
|
||||
created_time?: string[];
|
||||
updated_time?: string[];
|
||||
created_id?: number;
|
||||
updated_id?: number;
|
||||
}
|
||||
|
||||
export interface WorkflowNodeTypeTable extends BaseType {
|
||||
name?: string;
|
||||
code?: string;
|
||||
category?: string;
|
||||
func?: string;
|
||||
args?: string;
|
||||
kwargs?: string;
|
||||
sort_order?: number;
|
||||
is_active?: boolean;
|
||||
created_by?: CommonType;
|
||||
updated_by?: CommonType;
|
||||
deleted_by?: CommonType;
|
||||
}
|
||||
|
||||
export interface WorkflowNodeTypeForm {
|
||||
name: string;
|
||||
code: string;
|
||||
category?: string;
|
||||
func: string;
|
||||
args?: string;
|
||||
kwargs?: string;
|
||||
sort_order?: number;
|
||||
is_active?: boolean;
|
||||
}
|
||||
@@ -1,25 +1,115 @@
|
||||
import request from '@/utils/http'
|
||||
import { AppRouteRecord } from '@/types/router'
|
||||
/**
|
||||
* 系统管理相关聚合接口(表格示例、views/system/* 等使用的 `@/api/system-manage`)
|
||||
* 内部委托至 `module_system` 下各 API,并做分页字段与行展示字段映射。
|
||||
*/
|
||||
import MenuAPI, { type MenuTable } from "@/api/module_system/menu";
|
||||
import RoleAPI, { type RoleTable, type TablePageQuery } from "@/api/module_system/role";
|
||||
import UserAPI, { type UserInfo, type UserPageQuery } from "@/api/module_system/user";
|
||||
import type { AppRouteRecord } from "@/types/router";
|
||||
import { ResultEnum } from "@/enums/api/result.enum";
|
||||
|
||||
// 获取用户列表
|
||||
export function fetchGetUserList(params: Api.SystemManage.UserSearchParams) {
|
||||
return request.get<Api.SystemManage.UserList>({
|
||||
url: '/api/user/list',
|
||||
params
|
||||
})
|
||||
function assertSuccess<T>(res: { data: ApiResponse<T> }, fallbackMsg: string): T {
|
||||
if (res.data.code !== ResultEnum.SUCCESS || res.data.data == null) {
|
||||
throw new Error(res.data.msg || fallbackMsg);
|
||||
}
|
||||
return res.data.data;
|
||||
}
|
||||
|
||||
// 获取角色列表
|
||||
export function fetchGetRoleList(params: Api.SystemManage.RoleSearchParams) {
|
||||
return request.get<Api.SystemManage.RoleList>({
|
||||
url: '/api/role/list',
|
||||
params
|
||||
})
|
||||
/** useTable 传入 current / size 及演示页自定义筛选字段 */
|
||||
export async function fetchGetUserList(params: Record<string, unknown>) {
|
||||
const q: UserPageQuery = {
|
||||
page_no: Number(params.current) || 1,
|
||||
page_size: Number(params.size) || 20,
|
||||
username: (params.userName ?? params.name) as string | undefined,
|
||||
name: params.name as string | undefined,
|
||||
mobile: (params.userPhone ?? params.phone) as string | undefined,
|
||||
email: (params.userEmail ?? params.email) as string | undefined,
|
||||
status: params.status as string | undefined,
|
||||
};
|
||||
|
||||
const res = await UserAPI.listUser(q);
|
||||
const page = assertSuccess(res, "获取用户列表失败");
|
||||
|
||||
const items = (page.items || []).map((u) => mapUserToListRow(u));
|
||||
|
||||
return {
|
||||
items,
|
||||
total: page.total,
|
||||
page_no: page.page_no,
|
||||
page_size: page.page_size,
|
||||
has_next: page.has_next,
|
||||
};
|
||||
}
|
||||
|
||||
// 获取菜单列表
|
||||
export function fetchGetMenuList() {
|
||||
return request.get<AppRouteRecord[]>({
|
||||
url: '/api/v3/system/menus'
|
||||
})
|
||||
function mapUserToListRow(u: UserInfo) {
|
||||
return {
|
||||
id: u.id,
|
||||
nickName: u.name ?? u.username,
|
||||
userName: u.username,
|
||||
userGender: u.gender,
|
||||
userPhone: u.mobile,
|
||||
userEmail: u.email,
|
||||
avatar: u.avatar,
|
||||
status: u.status,
|
||||
};
|
||||
}
|
||||
|
||||
export async function fetchGetRoleList(params: Record<string, unknown>) {
|
||||
const q: TablePageQuery = {
|
||||
page_no: Number(params.current) || 1,
|
||||
page_size: Number(params.size) || 20,
|
||||
name: params.roleName as string | undefined,
|
||||
status:
|
||||
params.enabled !== undefined && params.enabled !== null && params.enabled !== ""
|
||||
? String(params.enabled)
|
||||
: undefined,
|
||||
};
|
||||
|
||||
const res = await RoleAPI.listRole(q);
|
||||
const page = assertSuccess(res, "获取角色列表失败");
|
||||
|
||||
const items = (page.items || []).map((r) => mapRoleToListRow(r));
|
||||
|
||||
return {
|
||||
items,
|
||||
total: page.total,
|
||||
page_no: page.page_no,
|
||||
page_size: page.page_size,
|
||||
has_next: page.has_next,
|
||||
};
|
||||
}
|
||||
|
||||
function mapRoleToListRow(r: RoleTable) {
|
||||
return {
|
||||
roleId: r.id,
|
||||
roleName: r.name,
|
||||
roleCode: r.code,
|
||||
description: r.description,
|
||||
enabled: r.status === "0",
|
||||
createTime: r.created_time,
|
||||
};
|
||||
}
|
||||
|
||||
function mapMenuTableToRoute(m: MenuTable): AppRouteRecord {
|
||||
const childrenRaw = m.children?.filter(Boolean) ?? [];
|
||||
const children = childrenRaw.length ? childrenRaw.map(mapMenuTableToRoute) : undefined;
|
||||
|
||||
return {
|
||||
path: (m.route_path ?? "").trim(),
|
||||
name: m.route_name,
|
||||
meta: {
|
||||
title: m.title ?? m.name ?? "",
|
||||
icon: m.icon,
|
||||
hidden: m.hidden,
|
||||
keepAlive: m.keep_alive,
|
||||
},
|
||||
children,
|
||||
};
|
||||
}
|
||||
|
||||
/** 菜单管理演示页:树形表格数据 */
|
||||
export async function fetchGetMenuList(): Promise<AppRouteRecord[]> {
|
||||
const res = await MenuAPI.listMenu({});
|
||||
const tree = assertSuccess(res, "获取菜单失败");
|
||||
return (tree || []).map(mapMenuTableToRoute);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user