feat(админка): выгрузка данных клиента

This commit is contained in:
anor
2026-11-06 23:09:01 +10:00
parent a47e948d6e
commit 904f492dd6
5 changed files with 131 additions and 0 deletions
+13
View File
@@ -160,6 +160,19 @@ async def customer_history(email: str, request: Request):
return {"items": data}
@router.get("/customers/{email}/export")
async def customer_export(email: str, request: Request):
user = require_admin(request)
data = await asyncio.to_thread(customers.export_zip, email)
if data is None:
raise HTTPException(404, "Клиент не найден")
db.log_action(user, "customer_export", "GET",
f"/api/admin/v2/customers/{email}/export", detail=f"{len(data)} байт")
from fastapi.responses import Response
return Response(data, media_type="application/zip",
headers={"Content-Disposition": f'attachment; filename="export.zip"'})
@router.post("/customers/{email}/topup")
async def customer_topup(email: str, request: Request):
user = require_admin(request)