feat: create structure for the project and first problem
This commit is contained in:
32
app/routers/grade_1.py
Normal file
32
app/routers/grade_1.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from app.problems.grade_1.join_pictures_with_quantity import (
|
||||
join_pictures_with_quantity,
|
||||
)
|
||||
from app.schemas.grade_1.join_pictures_with_quantity import (
|
||||
JoinPicturesWithQuantityProblem,
|
||||
JoinPicturesWithQuantityRequest,
|
||||
)
|
||||
|
||||
router = APIRouter(prefix="/grade_1", tags=["Grade 1"])
|
||||
|
||||
|
||||
@router.post(
|
||||
"/join_pictures_with_quantity",
|
||||
response_model=JoinPicturesWithQuantityProblem,
|
||||
)
|
||||
def create_join_pictures_with_quantity_problem(
|
||||
request: JoinPicturesWithQuantityRequest,
|
||||
) -> dict:
|
||||
try:
|
||||
return join_pictures_with_quantity(
|
||||
available_pictures=[
|
||||
picture.model_dump() for picture in request.available_pictures
|
||||
],
|
||||
container_count_per_side=request.container_count_per_side,
|
||||
min_quantity=request.min_quantity,
|
||||
max_quantity=request.max_quantity,
|
||||
seed=request.seed,
|
||||
)
|
||||
except ValueError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
Reference in New Issue
Block a user