db manager

This commit is contained in:
ryan
2026-06-10 12:08:38 +08:00
parent d05acd804f
commit 3ed4dec4a3
16 changed files with 2438 additions and 102 deletions
@@ -0,0 +1,41 @@
import {BaseService} from '@/lib/services';
import type {DBOverview, ExecuteSQLResponse, TableDataResponse} from './types';
/**
* 数据库管理服务类
*/
export class DbManageService extends BaseService {
protected static readonly basePath = '/api/v1/admin/db-manage';
/**
* 获取数据库运行概览
*/
static async getOverview(): Promise<DBOverview> {
return this.get<DBOverview>('/overview');
}
/**
* 获取数据库所有物理表名
*/
static async listTables(): Promise<string[]> {
return this.get<string[]>('/tables');
}
/**
* 获取某张数据表的数据(分页)
*/
static async getTableData(params: {
table: string;
page: number;
pageSize: number;
}): Promise<TableDataResponse> {
return this.get<TableDataResponse>('/table-data', params as unknown as Record<string, unknown>);
}
/**
* 在数据库中执行自定义 SQL 语句
*/
static async executeSQL(sql: string): Promise<ExecuteSQLResponse> {
return this.post<ExecuteSQLResponse>('/query', { sql });
}
}