This commit is contained in:
Your Name
2026-04-16 13:05:07 +08:00
commit 32efff1670
99 changed files with 9974 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
from pathlib import Path
from fastapi import APIRouter, HTTPException
from fastapi.responses import FileResponse
from app.schemas.common import ApiResponse
from app.services.export_service import create_export_file, list_exports
from app.core.files import exports_root
router = APIRouter(tags=["exports"])
@router.get("/exports", response_model=ApiResponse)
def export_list() -> ApiResponse:
return ApiResponse(data=list_exports())
@router.post("/exports/run", response_model=ApiResponse)
def export_run(payload: dict) -> ApiResponse:
record = create_export_file(payload)
return ApiResponse(message="导出文件已生成", data=record)
@router.get("/exports/download/{filename}")
def export_download(filename: str):
path = exports_root() / Path(filename).name
if not path.exists():
raise HTTPException(status_code=404, detail="文件不存在")
return FileResponse(path, filename=path.name)