2026-04-13 09:43:24 +08:00
|
|
|
# api/v1/history_router.py
|
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
|
import urllib.parse
|
|
|
|
|
|
2026-05-29 18:10:08 +08:00
|
|
|
from moldinsight.services.storage_integration_rustfs import StorageIntegrationService
|
|
|
|
|
from shared.database.database import get_db_session
|
2026-04-13 09:43:24 +08:00
|
|
|
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
|