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
+353
View File
@@ -547,6 +547,276 @@ const docTemplate = `{
}
}
},
"/api/v1/admin/db-manage/overview": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "获取数据库类型、版本、名称、文件大小、表数量及当前连接数,需要管理员权限",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "获取数据库运行概览",
"responses": {
"200": {
"description": "获取成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/db_manage.DBOverviewResponse"
}
}
}
]
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/db-manage/query": {
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "在当前数据库中执行任意自定义 SQL,如果是查询语句将返回格式化后的列与数据集,否则返回受影响行数,需要管理员权限",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "执行 SQL 查询",
"parameters": [
{
"description": "SQL 请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/db_manage.ExecuteSQLRequest"
}
}
],
"responses": {
"200": {
"description": "执行完毕",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/db_manage.ExecuteSQLResponse"
}
}
}
]
}
},
"400": {
"description": "SQL 语句错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/db-manage/table-data": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "根据传入的数据表名称进行分页数据查询,返回表结构列名及动态行数据,需要管理员权限",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "获取数据表数据",
"parameters": [
{
"type": "string",
"description": "表名称",
"name": "table",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "页码,默认 1",
"name": "page",
"in": "query"
},
{
"type": "integer",
"description": "每页大小,默认 10",
"name": "pageSize",
"in": "query"
}
],
"responses": {
"200": {
"description": "获取成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/db_manage.TableDataResponse"
}
}
}
]
}
},
"400": {
"description": "参数错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/db-manage/tables": {
"get": {
"security": [
{
"SessionCookie": []
}
],
"description": "返回当前数据库的所有用户自定义表名称列表,需要管理员权限",
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "获取数据库所有表名",
"responses": {
"200": {
"description": "获取成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
]
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/logs": {
"get": {
"security": [
@@ -3833,6 +4103,89 @@ const docTemplate = `{
}
}
},
"db_manage.DBOverviewResponse": {
"type": "object",
"properties": {
"connections": {
"type": "integer"
},
"name": {
"type": "string"
},
"size": {
"type": "string"
},
"table_count": {
"type": "integer"
},
"type": {
"type": "string"
},
"version": {
"type": "string"
}
}
},
"db_manage.ExecuteSQLRequest": {
"type": "object",
"required": [
"sql"
],
"properties": {
"sql": {
"type": "string"
}
}
},
"db_manage.ExecuteSQLResponse": {
"type": "object",
"properties": {
"affected_rows": {
"type": "integer"
},
"columns": {
"type": "array",
"items": {
"type": "string"
}
},
"execution_time_ms": {
"type": "integer"
},
"results": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
},
"type": {
"description": "\"select\" 或 \"exec\"",
"type": "string"
}
}
},
"db_manage.TableDataResponse": {
"type": "object",
"properties": {
"columns": {
"type": "array",
"items": {
"type": "string"
}
},
"results": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": true
}
},
"total": {
"type": "integer"
}
}
},
"logger.LogEntry": {
"type": "object",
"properties": {