重构路由

This commit is contained in:
2026-04-13 09:43:24 +08:00
parent d4f6017427
commit 8ad85bbd90
20 changed files with 1414 additions and 921 deletions
+37
View File
@@ -0,0 +1,37 @@
# api/v1/history_router.py
from fastapi import APIRouter, Depends
import urllib.parse
from services.storage_integration_rustfs import StorageIntegrationService
from database.database import get_db_session
from sqlalchemy.ext.asyncio import AsyncSession
router = APIRouter()
@router.get("/history")
@router.post("/history")
async def get_file_history(db_session: AsyncSession = Depends(get_db_session)):
"""获取按文件名分组的文件历史记录(支持多上传)"""
storage_service = StorageIntegrationService()
file_groups = await storage_service.get_all_file_groups(db_session)
return {
"total_files": len(file_groups),
"files": file_groups
}
@router.get("/history/{filename}")
@router.post("/history/{filename}")
async def get_file_records(filename: str, db_session: AsyncSession = Depends(get_db_session)):
"""获取指定文件名的所有上传记录(支持多上传历史)"""
decoded_filename = urllib.parse.unquote(filename)
storage_service = StorageIntegrationService()
file_records = await storage_service.get_file_history_by_filename(
db_session,
decoded_filename
)
return file_records