2026-01-27 02:52:02 +00:00
|
|
|
|
|
|
|
|
from fastapi import APIRouter, File, Form, UploadFile, Depends
|
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
from typing import Any, Dict, List, Optional
|
|
|
|
|
from services.upload_file.upload import handle_upload_file, handle_process_pdf, handle_to_postgis
|
|
|
|
|
from database.connection import engine
|
|
|
|
|
|
|
|
|
|
router = APIRouter()
|
|
|
|
|
|
|
|
|
|
@router.post("/file")
|
|
|
|
|
# async def upload_file(file: UploadFile = File(...), page: Optional[str] = Form(""), sheet: Optional[str] = Form(""), user = Depends(require_role("admin"))):
|
|
|
|
|
async def upload_file(file: UploadFile = File(...), page: Optional[str] = Form(""), sheet: Optional[str] = Form(""), file_desc: Optional[str] = Form("")):
|
|
|
|
|
return await handle_upload_file(file, page, sheet, file_desc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PdfRequest(BaseModel):
|
|
|
|
|
title: str
|
|
|
|
|
columns: List[str]
|
|
|
|
|
rows: List[List]
|
|
|
|
|
fileName: str
|
|
|
|
|
fileDesc: str
|
|
|
|
|
|
|
|
|
|
@router.post("/process-pdf")
|
|
|
|
|
async def upload_file(payload: PdfRequest):
|
|
|
|
|
return await handle_process_pdf(payload)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UploadRequest(BaseModel):
|
|
|
|
|
title: str
|
2026-02-10 01:54:35 +00:00
|
|
|
path: str
|
2026-01-27 02:52:02 +00:00
|
|
|
rows: List[dict]
|
|
|
|
|
columns: List[str]
|
|
|
|
|
author: Dict[str, Any]
|
|
|
|
|
style: str
|
|
|
|
|
|
|
|
|
|
@router.post("/to-postgis")
|
|
|
|
|
async def upload_to_postgis(payload: UploadRequest):
|
|
|
|
|
# return await handle_to_postgis(payload, engine)
|
|
|
|
|
return await handle_to_postgis(payload)
|