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

online_pre_select_service_router = APIRouter()

@online_pre_select_service_router.post("/create_online_pre_select_service", response_model_exclude_none=True)
async def create_online_pre_select_service(request:List[schema.OnlinePreSelectServiceCreate], db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await OnlinePreSelectServiceService(db,token).created(request)

@online_pre_select_service_router.get("/get_online_pre_select_service{group_id}", response_model_exclude_none=True)
async def get_online_pre_select_service(group_id:int, db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await OnlinePreSelectServiceService(db,token).geted(group_id)

@online_pre_select_service_router.put("/update_online_pre_select_service", response_model_exclude_none=True)
async def update_online_pre_select_service(request:List[schema.OnlinePreSelectServiceUpdate], db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await OnlinePreSelectServiceService(db,token).updated(request)

@online_pre_select_service_router.delete("/delete_online_pre_select_service", response_model_exclude_none=True)
async def delete_online_pre_select_service(online_id:int, db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await OnlinePreSelectServiceService(db,token).deleted(online_id)


