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

online_store_format_router = APIRouter()

@online_store_format_router.post("/create_online_store_format", response_model_exclude_none=True)
async def create_online_store_format(request: List[schema.OnlineStoreFormatCreate],db: Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await OnlineStoreFormatService(db, token).created(request)

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

@online_store_format_router.put("/update_online_store_format", response_model_exclude_none=True)
async def update_online_store_format(request:List[schema.OnlineStoreFormatUpdate], db:Session = Depends(get_db),token: JWTPayloadSchema = Depends(get_current_student)):
    return await OnlineStoreFormatService(db,token).updated(request)

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