mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 22:31:21 +00:00
1. 统一所有API文件的request导入路径,从@utils/http改为@utils 2. 合并工具类导出,将分散的工具模块整合到@utils统一出口 3. 重构状态管理导入路径,统一从@utils导入相关工具与store 4. 整理组件导入与样式引用,优化项目内组件与样式的引用路径 5. 新增部分基础组件与工具方法,完善项目基础能力 6. 修复部分样式类名的书写规范,统一类名格式
125 lines
2.4 KiB
TypeScript
125 lines
2.4 KiB
TypeScript
import { request } from "@utils";
|
|
|
|
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>;
|
|
}
|