refactor: 数据源菜单合一+布局优化
- 4个数据源菜单(MySQL/PG/Redis/Mongo)合并为1个「数据源」 - InstancePage 改为统一入口,顶部Tab切换类型过滤 - 添加数据源改为弹框Modal(默认MySQL) - 去掉左下角用户区,退出登录移到右上角header - 侧边栏收窄220px,整体布局更紧凑 - 后端202 tests passing - 前端构建零错误
This commit is contained in:
1 parent
bab55d3927
commit
5cbd0e3441
23 files changed
+2881
-94
No files matched your search
@@ -0,0 +1,70 @@
|
||||
"""数据字典 API 端点。"""
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.security import require_role
|
||||
from app.models.user import User
|
||||
from app.services import dictionary_service
|
||||
|
||||
router = APIRouter(tags=["数据字典"])
|
||||
|
||||
|
||||
@router.get("/instances/{instance_id}/databases")
|
||||
async def list_databases(
|
||||
instance_id: int,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(require_role("admin", "dba", "developer")),
|
||||
):
|
||||
"""获取实例的数据库列表。"""
|
||||
databases = await dictionary_service.list_databases(db, instance_id)
|
||||
if databases is None:
|
||||
raise HTTPException(status_code=404, detail="数据源不存在")
|
||||
return {"databases": databases}
|
||||
|
||||
|
||||
@router.get("/instances/{instance_id}/tables")
|
||||
async def list_tables(
|
||||
instance_id: int,
|
||||
database: str = Query(..., description="数据库名"),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(require_role("admin", "dba", "developer")),
|
||||
):
|
||||
"""获取指定数据库的表列表。"""
|
||||
tables = await dictionary_service.list_tables(db, instance_id, database)
|
||||
if tables is None:
|
||||
raise HTTPException(status_code=404, detail="数据源不存在")
|
||||
return {"tables": tables}
|
||||
|
||||
|
||||
@router.get("/instances/{instance_id}/tables/{table_name}")
|
||||
async def get_table_detail(
|
||||
instance_id: int,
|
||||
table_name: str,
|
||||
database: str = Query(..., description="数据库名"),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(require_role("admin", "dba", "developer")),
|
||||
):
|
||||
"""获取表详情: 字段/索引/DDL/行数。"""
|
||||
detail = await dictionary_service.get_table_detail(
|
||||
db, instance_id, database, table_name
|
||||
)
|
||||
if not detail:
|
||||
raise HTTPException(status_code=404, detail="数据源不存在")
|
||||
return detail
|
||||
|
||||
|
||||
@router.get("/instances/{instance_id}/export")
|
||||
async def export_dictionary(
|
||||
instance_id: int,
|
||||
database: str = Query(..., description="数据库名"),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
current_user: User = Depends(require_role("admin", "dba", "developer")),
|
||||
):
|
||||
"""导出整个数据库的表结构信息。"""
|
||||
result = await dictionary_service.export_dictionary(
|
||||
db, instance_id, database
|
||||
)
|
||||
return {"tables": result}
|
||||
Reference in new issue
Block a user