from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession

from app.db.session import get_db
from app.module.dataset.schema.pdf_extract import PdfTextExtractRequest, PdfTextExtractResponse
from app.module.dataset.service.pdf_extract import PdfTextExtractService
from app.module.shared.schema.common import StandardResponse

router = APIRouter(
    prefix="",
    tags=["dataset"],
)


@router.post("/pdf-text-extract", response_model=StandardResponse[PdfTextExtractResponse])
async def extract_pdf_text(
    request: PdfTextExtractRequest,
    db: AsyncSession = Depends(get_db),
):
    service = PdfTextExtractService(db)
    result = await service.extract_pdf_to_text(request.dataset_id, request.file_id)
    return StandardResponse(code=200, message="Success", data=result)
