from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.api.vessel_list.schemas import VesseResponce, VesseUpdate, VesselCreat
from app.api.vessel_list.service import VesselService
from app.database.main.mysql import get_db
from app.dependency.authantication import JWTManager

vessel_router = APIRouter()

@vessel_router.post("/vessel", response_model_exclude_none=True)
async def create_comapany(request: VesselCreat,db: Session = Depends(get_db),token: dict = Depends(JWTManager.verify_token)):
    return await VesselService(db, token).create_vessel(request)

@vessel_router.get("/vessel_list/{vessel_id}",response_model=VesseResponce,response_model_exclude_none=True)
async def get_company(vessel_id: int,db: Session = Depends(get_db),token: dict = Depends(JWTManager.verify_token)):
    return await VesselService(db, token).get_vessel(vessel_id)

@vessel_router.put("/vessel_list/update", response_model_exclude_none=True)
async def update_vessel(request: VesseUpdate,db: Session = Depends(get_db),token: dict = Depends(JWTManager.verify_token)):
    return await VesselService(db, token).update_vessel(request)
