from typing import List
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.api.location_spillage_factor_analysis import schema, service
from app.database.main.mysql import get_db
from app.dependency.authantication import JWTPayloadSchema, get_current_student

location_spillage_router = APIRouter()

@location_spillage_router.post("/create_location_spillage", response_model_exclude_none=True)
async def create_location_spillage(request:schema.LocationSpillageFactorCreate, db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await service.LocationSpillageFactorAnalysisService(db,token).create_location(request)

@location_spillage_router.get("/get_location_spillage/{group_id}", response_model_exclude_none=True)
async def get_location_spillage(group_id:int, db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await service.LocationSpillageFactorAnalysisService(db,token).get_location(group_id)

@location_spillage_router.put("/update_location_spillage", response_model_exclude_none=True)
async def update_location_spillage(request:List[schema.LocationSpillageFactorUpdate], db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await service.LocationSpillageFactorAnalysisService(db,token).update_location1(request)

@location_spillage_router.delete("/delete_location_spillage", response_model_exclude_none=True)
async def delete_location_spillage(location_id:int, db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await service.LocationSpillageFactorAnalysisService(db,token).delete_location(location_id)