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

optimising_assets_router = APIRouter()

@optimising_assets_router.post("/create_optimising_assets", response_model_exclude_none=True)
async def create_optimising_assets(request:schema.OptimisingAssetsCreate, db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await service.OptimisingAssetsService(db,token).create_optimising_assets(request)

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

@optimising_assets_router.put("/update_optimising_assets", response_model_exclude_none=True)
async def update_optimising_assets(request:List[schema.OptimisingAssetsUpdate], db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await service.OptimisingAssetsService(db,token).update_optimising_assets(request)

@optimising_assets_router.delete("/delete_optimising_assets", response_model_exclude_none=True)
async def delete_optimising_assets(optimising_id:int, db:Session = Depends(get_db), token:JWTPayloadSchema = Depends(get_current_student)):
    return await service.OptimisingAssetsService(db,token).delete_optimising_assets(optimising_id)
