FEAT: Integrated Document Engine with WebP optimization, Thumbnail generation and Hybrid (NAS/SSD) storage logic
This commit is contained in:
Binary file not shown.
@@ -1,16 +1,19 @@
|
||||
from fastapi import APIRouter
|
||||
from app.api.v1.endpoints import auth, catalog, assets, organizations
|
||||
from app.api.v1.endpoints import auth, catalog, assets, organizations, documents # <--- Ide bekerült a documents!
|
||||
|
||||
api_router = APIRouter()
|
||||
|
||||
# Felhasználó és Identitás
|
||||
# Hitelesítés
|
||||
api_router.include_router(auth.router, prefix="/auth", tags=["Authentication"])
|
||||
|
||||
# Katalógus és Jármű Robotok
|
||||
# Katalógus
|
||||
api_router.include_router(catalog.router, prefix="/catalog", tags=["Vehicle Catalog"])
|
||||
|
||||
# Egyedi Eszközök (Assets)
|
||||
# Eszközök (Járművek)
|
||||
api_router.include_router(assets.router, prefix="/assets", tags=["Assets"])
|
||||
|
||||
# Szervezetek és Onboarding
|
||||
api_router.include_router(organizations.router, prefix="/organizations", tags=["Organizations"])
|
||||
# Szervezetek
|
||||
api_router.include_router(organizations.router, prefix="/organizations", tags=["Organizations"])
|
||||
|
||||
# DOKUMENTUMOK (Ez az új rész, ami hiányzik neked)
|
||||
api_router.include_router(documents.router, prefix="/documents", tags=["Documents"])
|
||||
Binary file not shown.
30
backend/app/api/v1/endpoints/documents.py
Normal file
30
backend/app/api/v1/endpoints/documents.py
Normal file
@@ -0,0 +1,30 @@
|
||||
from fastapi import APIRouter, Depends, UploadFile, File, BackgroundTasks, HTTPException
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
from app.db.session import get_db
|
||||
from app.services.document_service import DocumentService
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/upload/{parent_type}/{parent_id}")
|
||||
async def upload_document(
|
||||
parent_type: str,
|
||||
parent_id: str,
|
||||
background_tasks: BackgroundTasks,
|
||||
file: UploadFile = File(...),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
Dokumentum feltöltés, optimalizálás és NAS-ra mentés.
|
||||
parent_type: 'organizations' vagy 'assets'
|
||||
"""
|
||||
if parent_type not in ["organizations", "assets"]:
|
||||
raise HTTPException(status_code=400, detail="Érvénytelen cél-típus!")
|
||||
|
||||
doc = await DocumentService.process_upload(file, parent_type, parent_id, db, background_tasks)
|
||||
|
||||
return {
|
||||
"document_id": doc.id,
|
||||
"thumbnail": doc.thumbnail_path,
|
||||
"original_name": doc.original_name,
|
||||
"status": "processed_and_vaulted"
|
||||
}
|
||||
Reference in New Issue
Block a user