feat: 资产 CRUD API + 统计接口 + Vue3 管理前端(可选 API Key 鉴权)

This commit is contained in:
gouki
2026-08-01 15:39:13 +00:00
parent e29154518b
commit 1dac5d8735
20 changed files with 1105 additions and 3 deletions
+8 -1
View File
@@ -1,8 +1,9 @@
"""SQLite 数据库连接与初始化"""
from pathlib import Path
from typing import Generator
from sqlmodel import SQLModel, create_engine
from sqlmodel import Session, SQLModel, create_engine
BASE_DIR = Path(__file__).resolve().parent.parent
DATA_DIR = BASE_DIR / "data"
@@ -19,3 +20,9 @@ def init_db() -> None:
from app.models.asset import AIAccount, Asset, DomainDetail, VPSDetail # noqa: F401
SQLModel.metadata.create_all(engine)
def get_session() -> Generator[Session, None, None]:
"""FastAPI 依赖:提供数据库会话(请求结束后自动关闭)"""
with Session(engine) as session:
yield session