19 lines
528 B
Python
19 lines
528 B
Python
# Entity: Food
|
|
|
|
from fastapi import APIRouter, Depends, status
|
|
from sqlalchemy.orm import Session
|
|
from typing import List
|
|
from core.database import get_db
|
|
from models.food import Food
|
|
from schemas.food import FoodSchema, FoodCreate
|
|
from helpers.food_helpers import create_foods
|
|
|
|
router = APIRouter()
|
|
|
|
@router.post("/food", status_code=201, response_model=List[FoodSchema])
|
|
async def add_foods(
|
|
foods: List[FoodCreate],
|
|
db: Session = Depends(get_db)
|
|
):
|
|
created_foods = create_foods(db, foods)
|
|
return created_foods |