from fastapi import APIRouter, Depends, UploadFile,File
from sqlalchemy.orm import Session
from app.api.category_definition_excel.service import CategoryDefinitionExcelService
from app.database.main.mysql import get_db
from app.dependency.authantication import JWTPayloadSchema, get_current_student

category_definition_excel_router = APIRouter()

@category_definition_excel_router.get("/download_excel")
async def download_excel(db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await CategoryDefinitionExcelService(db,token).download_excel()

@category_definition_excel_router.post("/upload_excel")
async def upload_excel(file: UploadFile = File(...), db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await CategoryDefinitionExcelService(db,token).upload_excel(file)
