mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-04 15:06:37 +08:00
42 lines
1.0 KiB
TypeScript
42 lines
1.0 KiB
TypeScript
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 });
|
|
}
|
|
}
|