mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-05 17:27:47 +00:00
refactor: 完成项目代码结构优化与权限清理
主要变更: 1. 重构健康检查模块,迁移目录结构并合并重复代码 2. 清理路由标签冗余的"系统管理/平台管理"前缀,简化标签名称 3. 重构工作流相关目录与API,统一命名为flow和nodes 4. 重命名缓存删除接口为clear,同步前后端路由与权限 5. 简化接口参数描述,统一批量状态修改的请求体格式 6. 重构动态路由加载逻辑,优化初始化流程 7. 清理废弃的self_service模块,整合租户自助服务到租户API 8. 重构发票管理接口,统一路由前缀与权限控制 9. 优化代码生成模板,补全参数注解与描述 10: 修复日志删除接口的参数解析逻辑
This commit is contained in:
@@ -47,7 +47,7 @@ const CacheAPI = {
|
||||
|
||||
deleteCacheAll() {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/delete/all`,
|
||||
url: `${API_PATH}/clear`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
@@ -95,7 +95,7 @@ export const ResourceAPI = {
|
||||
*/
|
||||
createDirectory(body: ResourceCreateDirQuery) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/create-dir`,
|
||||
url: `${API_PATH}/mkdir`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { request } from "@utils";
|
||||
|
||||
const PLATFORM_API = "/platform/invoice";
|
||||
const TENANT_API = "/platform/tenant/invoice";
|
||||
const API_PATH = "/invoice";
|
||||
|
||||
const InvoiceAPI = {
|
||||
// ─── 平台端 ───
|
||||
listInvoices(query?: InvoicePageQuery) {
|
||||
return request<ApiResponse<{ list: InvoiceTable[]; total: number }>>({
|
||||
url: `${PLATFORM_API}/list`,
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
@@ -15,7 +14,7 @@ const InvoiceAPI = {
|
||||
|
||||
issueInvoice(invoiceId: number, body: { pdf_url?: string; api_response?: string }) {
|
||||
return request<ApiResponse>({
|
||||
url: `${PLATFORM_API}/issue/${invoiceId}`,
|
||||
url: `${API_PATH}/issue/${invoiceId}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
@@ -23,7 +22,7 @@ const InvoiceAPI = {
|
||||
|
||||
voidInvoice(invoiceId: number, reason?: string) {
|
||||
return request<ApiResponse>({
|
||||
url: `${PLATFORM_API}/void/${invoiceId}`,
|
||||
url: `${API_PATH}/void/${invoiceId}`,
|
||||
method: "put",
|
||||
data: { description: reason },
|
||||
});
|
||||
@@ -32,7 +31,7 @@ const InvoiceAPI = {
|
||||
// ─── 租户端 ───
|
||||
tenantListInvoices(query?: InvoicePageQuery) {
|
||||
return request<ApiResponse<{ list: InvoiceTable[]; total: number }>>({
|
||||
url: `${TENANT_API}/list`,
|
||||
url: `${API_PATH}/mine/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
@@ -40,7 +39,7 @@ const InvoiceAPI = {
|
||||
|
||||
applyInvoice(body: InvoiceApplyForm) {
|
||||
return request<ApiResponse>({
|
||||
url: `${TENANT_API}/apply`,
|
||||
url: `${API_PATH}/apply`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
@@ -48,7 +47,7 @@ const InvoiceAPI = {
|
||||
|
||||
downloadInvoice(invoiceId: number) {
|
||||
return request<Blob>({
|
||||
url: `${TENANT_API}/${invoiceId}/download`,
|
||||
url: `${API_PATH}/${invoiceId}/download`,
|
||||
method: "get",
|
||||
responseType: "blob",
|
||||
});
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
import { request } from "@utils";
|
||||
|
||||
// ─── 平台订单 ──────────────────────────────────────────
|
||||
const ORDER_API = "/platform/order";
|
||||
const PAYMENT_API = "/platform/payment";
|
||||
const REFUND_API = "/platform/refund";
|
||||
const TENANT_ORDER_API = "/tenant/order";
|
||||
const API_PATH = "/platform/order";
|
||||
|
||||
const OrderAPI = {
|
||||
// ─── 订单管理 ───
|
||||
listOrders(query?: OrderPageQuery) {
|
||||
return request<ApiResponse<{ items: OrderTable[]; total: number }>>({
|
||||
url: `${ORDER_API}/list`,
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
@@ -18,14 +15,14 @@ const OrderAPI = {
|
||||
|
||||
detailOrder(orderId: number) {
|
||||
return request<ApiResponse<OrderTable>>({
|
||||
url: `${ORDER_API}/detail/${orderId}`,
|
||||
url: `${API_PATH}/detail/${orderId}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
createOrder(body: OrderCreateForm) {
|
||||
return request<ApiResponse<{ id: number; order_no: string }>>({
|
||||
url: `${ORDER_API}/create`,
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
@@ -33,32 +30,32 @@ const OrderAPI = {
|
||||
|
||||
cancelOrder(orderId: number) {
|
||||
return request<ApiResponse<{ message: string }>>({
|
||||
url: `${ORDER_API}/cancel/${orderId}`,
|
||||
url: `${API_PATH}/cancel/${orderId}`,
|
||||
method: "post",
|
||||
});
|
||||
},
|
||||
|
||||
// ─── 支付操作 ───
|
||||
payOrder(orderId: number, body?: { pay_method?: string }) {
|
||||
payOrder(orderId: number, method?: string) {
|
||||
return request<
|
||||
ApiResponse<{ order_no: string; amount: number; qr_code_url?: string; pay_url?: string }>
|
||||
>({
|
||||
url: `${PAYMENT_API}/pay/${orderId}`,
|
||||
url: `${API_PATH}/pay/${orderId}`,
|
||||
method: "post",
|
||||
data: body,
|
||||
params: method ? { method } : undefined,
|
||||
});
|
||||
},
|
||||
|
||||
queryPaymentStatus(orderId: number) {
|
||||
return request<ApiResponse<{ paid: boolean; order_no?: string; amount?: number }>>({
|
||||
url: `${PAYMENT_API}/status/${orderId}`,
|
||||
url: `${API_PATH}/status/${orderId}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
mockPaymentCallback(orderId: number) {
|
||||
return request<ApiResponse>({
|
||||
url: `${PAYMENT_API}/mock/callback`,
|
||||
url: `${API_PATH}/mock/callback`,
|
||||
method: "post",
|
||||
data: { order_id: orderId },
|
||||
});
|
||||
@@ -67,7 +64,7 @@ const OrderAPI = {
|
||||
// ─── 支付记录 ───
|
||||
listPaymentRecords(query?: PageQuery) {
|
||||
return request<ApiResponse<{ items: PaymentRecordTable[]; total: number }>>({
|
||||
url: `${PAYMENT_API}/record/list`,
|
||||
url: `${API_PATH}/record/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
@@ -76,7 +73,7 @@ const OrderAPI = {
|
||||
// ─── 退款管理 ───
|
||||
listRefunds(query?: RefundPageQuery) {
|
||||
return request<ApiResponse<{ items: RefundTable[]; total: number }>>({
|
||||
url: `${REFUND_API}/list`,
|
||||
url: `${API_PATH}/refund/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
@@ -84,14 +81,14 @@ const OrderAPI = {
|
||||
|
||||
approveRefund(refundId: number) {
|
||||
return request<ApiResponse<{ message: string }>>({
|
||||
url: `${REFUND_API}/approve/${refundId}`,
|
||||
url: `${API_PATH}/approve/${refundId}`,
|
||||
method: "put",
|
||||
});
|
||||
},
|
||||
|
||||
rejectRefund(refundId: number, body: { reject_reason?: string }) {
|
||||
return request<ApiResponse<{ message: string }>>({
|
||||
url: `${REFUND_API}/reject/${refundId}`,
|
||||
url: `${API_PATH}/reject/${refundId}`,
|
||||
method: "put",
|
||||
data: body,
|
||||
});
|
||||
@@ -106,7 +103,7 @@ const OrderAPI = {
|
||||
pay_method?: string;
|
||||
}) {
|
||||
return request<ApiResponse<{ id: number; order_no: string }>>({
|
||||
url: `${TENANT_ORDER_API}/create`,
|
||||
url: `${API_PATH}/tenant/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
@@ -114,7 +111,7 @@ const OrderAPI = {
|
||||
|
||||
tenantApplyRefund(orderId: number, body: { reason: string }) {
|
||||
return request<ApiResponse<{ id: number }>>({
|
||||
url: `${TENANT_ORDER_API}/refund/apply/${orderId}`,
|
||||
url: `${API_PATH}/tenant/refund/apply/${orderId}`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
|
||||
@@ -1,152 +0,0 @@
|
||||
import { request } from "@utils";
|
||||
|
||||
const API_PATH = "/platform/tenant";
|
||||
|
||||
const SelfServiceAPI = {
|
||||
/** 可选购的套餐列表 */
|
||||
getAvailablePackages() {
|
||||
return request<ApiResponse<{ packages: AvailablePackage[] }>>({
|
||||
url: `${API_PATH}/package/available`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 套餐变更预览 */
|
||||
previewPackageChange(packageId: number) {
|
||||
return request<ApiResponse<PackageChangePreview>>({
|
||||
url: `${API_PATH}/package/preview`,
|
||||
method: "get",
|
||||
params: { target_package_id: packageId },
|
||||
});
|
||||
},
|
||||
|
||||
/** 创建自助订单 */
|
||||
createOrder(body: SelfServiceOrderForm) {
|
||||
return request<ApiResponse<{ order_id: number; amount: number }>>({
|
||||
url: `${API_PATH}/order/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 我的订单列表 */
|
||||
listMyOrders(query?: PageQuery) {
|
||||
return request<ApiResponse<PageResult<SelfServiceOrderItem>>>({
|
||||
url: `${API_PATH}/order/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/** 订单详情 */
|
||||
detailMyOrder(orderId: number) {
|
||||
return request<ApiResponse<SelfServiceOrderItem>>({
|
||||
url: `${API_PATH}/order/detail/${orderId}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 租户工作台概览 */
|
||||
getWorkspace() {
|
||||
return request<ApiResponse<WorkspaceData>>({
|
||||
url: `${API_PATH}/workspace`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 购买付费插件 */
|
||||
purchasePlugin(body: { plugin_id: number; pay_method?: string }) {
|
||||
return request<ApiResponse<{ id: number; order_no: string }>>({
|
||||
url: `${API_PATH}/plugin/purchase`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default SelfServiceAPI;
|
||||
|
||||
export interface AvailablePackage {
|
||||
id: number;
|
||||
name: string;
|
||||
price: number;
|
||||
period: string;
|
||||
trial_days: number;
|
||||
max_users: number;
|
||||
max_roles: number;
|
||||
max_depts: number;
|
||||
max_storage_mb: number;
|
||||
description: string | null;
|
||||
is_current: boolean;
|
||||
available_actions: string[];
|
||||
}
|
||||
|
||||
export interface PackageChangePreview {
|
||||
current_package: string;
|
||||
target_package: string;
|
||||
action: string;
|
||||
amount: number;
|
||||
period: string;
|
||||
gained_menus: { id: number; name: string; path: string }[];
|
||||
lost_menus: { id: number; name: string; path: string }[];
|
||||
affected_roles: string[];
|
||||
affected_users: number;
|
||||
}
|
||||
|
||||
export interface SelfServiceOrderForm {
|
||||
package_id: number;
|
||||
order_type: "buy" | "renew" | "upgrade" | "downgrade";
|
||||
pay_method?: string;
|
||||
}
|
||||
|
||||
export interface SelfServiceOrderItem {
|
||||
id: number;
|
||||
order_no: string;
|
||||
package_name: string;
|
||||
order_type: string;
|
||||
amount: number;
|
||||
status: number;
|
||||
pay_method?: string;
|
||||
pay_time?: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface WorkspaceData {
|
||||
tenant: {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
status: number;
|
||||
status_label: string;
|
||||
start_time: string | null;
|
||||
end_time: string | null;
|
||||
days_remaining: number;
|
||||
};
|
||||
package: {
|
||||
id: number;
|
||||
name: string;
|
||||
price: number;
|
||||
period: string;
|
||||
} | null;
|
||||
quota: {
|
||||
max_users: number;
|
||||
max_roles: number;
|
||||
max_depts: number;
|
||||
current_users: number;
|
||||
current_roles: number;
|
||||
current_depts: number;
|
||||
usage_percent: {
|
||||
users: number;
|
||||
roles: number;
|
||||
depts: number;
|
||||
};
|
||||
};
|
||||
recent_orders: {
|
||||
id: number;
|
||||
order_no: string;
|
||||
amount: number;
|
||||
order_type: string;
|
||||
status: number;
|
||||
created_at: string | null;
|
||||
}[];
|
||||
}
|
||||
@@ -126,6 +126,66 @@ const TenantAPI = {
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 可选购的套餐列表 */
|
||||
getAvailablePackages() {
|
||||
return request<ApiResponse<{ packages: AvailablePackage[] }>>({
|
||||
url: `${API_PATH}/package/available`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 套餐变更预览 */
|
||||
previewPackageChange(packageId: number) {
|
||||
return request<ApiResponse<PackageChangePreview>>({
|
||||
url: `${API_PATH}/package/preview`,
|
||||
method: "get",
|
||||
params: { target_package_id: packageId },
|
||||
});
|
||||
},
|
||||
|
||||
/** 创建自助订单 */
|
||||
createOrder(body: SelfServiceOrderForm) {
|
||||
return request<ApiResponse<{ order_id: number; amount: number }>>({
|
||||
url: `${API_PATH}/order/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 我的订单列表 */
|
||||
listMyOrders(query?: PageQuery) {
|
||||
return request<ApiResponse<PageResult<SelfServiceOrderItem>>>({
|
||||
url: `${API_PATH}/order/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/** 订单详情 */
|
||||
detailMyOrder(orderId: number) {
|
||||
return request<ApiResponse<SelfServiceOrderItem>>({
|
||||
url: `${API_PATH}/order/detail/${orderId}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 租户工作台概览 */
|
||||
getWorkspace() {
|
||||
return request<ApiResponse<WorkspaceData>>({
|
||||
url: `${API_PATH}/workspace`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 购买付费插件 */
|
||||
purchasePlugin(body: { plugin_id: number; pay_method?: string }) {
|
||||
return request<ApiResponse<{ id: number; order_no: string }>>({
|
||||
url: `${API_PATH}/plugin/purchase`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default TenantAPI;
|
||||
@@ -273,3 +333,88 @@ export interface TenantConfigItem {
|
||||
config_key: string;
|
||||
config_value: string | null;
|
||||
}
|
||||
|
||||
export interface AvailablePackage {
|
||||
id: number;
|
||||
name: string;
|
||||
price: number;
|
||||
period: string;
|
||||
trial_days: number;
|
||||
max_users: number;
|
||||
max_roles: number;
|
||||
max_depts: number;
|
||||
max_storage_mb: number;
|
||||
description: string | null;
|
||||
is_current: boolean;
|
||||
available_actions: string[];
|
||||
}
|
||||
|
||||
export interface PackageChangePreview {
|
||||
current_package: string;
|
||||
target_package: string;
|
||||
action: string;
|
||||
amount: number;
|
||||
period: string;
|
||||
gained_menus: { id: number; name: string; path: string }[];
|
||||
lost_menus: { id: number; name: string; path: string }[];
|
||||
affected_roles: Record<string, unknown>[];
|
||||
affected_users: number;
|
||||
}
|
||||
|
||||
export interface SelfServiceOrderForm {
|
||||
package_id: number;
|
||||
order_type: "buy" | "renew" | "upgrade" | "downgrade";
|
||||
pay_method?: string;
|
||||
}
|
||||
|
||||
export interface SelfServiceOrderItem {
|
||||
id: number;
|
||||
order_no: string;
|
||||
package_name: string;
|
||||
order_type: string;
|
||||
amount: number;
|
||||
status: number;
|
||||
pay_method?: string;
|
||||
pay_time?: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface WorkspaceData {
|
||||
tenant: {
|
||||
id: number;
|
||||
name: string;
|
||||
code: string;
|
||||
status: number;
|
||||
status_label: string;
|
||||
start_time: string | null;
|
||||
end_time: string | null;
|
||||
days_remaining: number;
|
||||
};
|
||||
package: {
|
||||
id: number;
|
||||
name: string;
|
||||
price: number;
|
||||
period: string;
|
||||
} | null;
|
||||
quota: {
|
||||
max_users: number;
|
||||
max_roles: number;
|
||||
max_depts: number;
|
||||
current_users: number;
|
||||
current_roles: number;
|
||||
current_depts: number;
|
||||
usage_percent: {
|
||||
users: number;
|
||||
roles: number;
|
||||
depts: number;
|
||||
};
|
||||
};
|
||||
recent_orders: {
|
||||
id: number;
|
||||
order_no: string;
|
||||
amount: number;
|
||||
order_type: string;
|
||||
status: number;
|
||||
created_at: string | null;
|
||||
}[];
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import { request } from "@utils";
|
||||
|
||||
/** 对应后端 `plugin.module_task.workflow.definition` */
|
||||
const API_PATH = "/task/workflow/definition";
|
||||
/** 对应后端 `plugin.module_task.workflow.flow` */
|
||||
const API_PATH = "/task/workflow/flow";
|
||||
|
||||
const WorkflowDefinitionAPI = {
|
||||
getWorkflowList(query: WorkflowPageQuery) {
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import { request } from "@utils";
|
||||
|
||||
/** 对应后端 `plugin.module_task.workflow.node_type` */
|
||||
const API_PATH = "/task/workflow/node-type";
|
||||
const API_PATH = "/task/workflow/nodes";
|
||||
|
||||
const WorkflowNodeTypeAPI = {
|
||||
getWorkflowNodeTypeOptions() {
|
||||
Reference in New Issue
Block a user