From dc4533d82f804a0c60039001785a1b5d92962fd9 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Mon, 14 Apr 2025 15:48:09 +0000 Subject: [PATCH] feat: Generated endpoint endpoints/routeoptimization.post.py via AI for Route --- endpoints/routeoptimization.post.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/endpoints/routeoptimization.post.py b/endpoints/routeoptimization.post.py index e69de29..33fdd6a 100644 --- a/endpoints/routeoptimization.post.py +++ b/endpoints/routeoptimization.post.py @@ -0,0 +1,19 @@ +from fastapi import APIRouter, Depends +from sqlalchemy.orm import Session +from core.database import get_db +from schemas.route import RouteSchema, RouteCreate +from helpers.route_helpers import create_route, validate_unique_route + +router = APIRouter() + +@router.post("/routeoptimization", status_code=201, response_model=RouteSchema) +async def optimize_route( + route_data: RouteCreate, + db: Session = Depends(get_db) +): + if not validate_unique_route(db, route_data): + # Handle duplicate route error + return {"error": "Route with the same name or path already exists."} + + new_route = create_route(db, route_data) + return new_route \ No newline at end of file