o
    
hò  ã                   @   sÒ   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	 d dl
m	ZmZ eddgdZejd	ee d
eeƒfdedefdd„ƒZejd	ed
eeƒfdedefdd„ƒZe d¡eeƒfdedefdd„ƒZdS )é    )Ú	APIRouterÚDependsÚHTTPException)ÚSession)Úget_db)ÚMealFood)r   ÚMealFoodBasez
/mealfoodsÚ	mealfoods)ÚprefixÚtagsú/)Úresponse_modelÚmeal_idÚdbc                 C   s   |  t¡ tj| k¡ ¡ S )N)Úqueryr   Úfilterr   Úall)r   r   © r   ú+C:\MealPlanner\backend\routers\mealfoods.pyÚlist_mealfoods	   s   r   Úmealfoodc                 C   s2   t di |  ¡ ¤Ž}| |¡ | ¡  | |¡ |S )Nr   )r   ÚdictÚaddÚcommitÚrefresh)r   r   Úmfr   r   r   Úcreate_mealfood   s
   

r   z/{mealfood_id}Úmealfood_idc                 C   sD   |  t¡ tj| k¡ ¡ }|stddd‚| |¡ | ¡  ddiS )Ni”  zMealFood non trovato)Ústatus_codeÚdetailÚokT)r   r   r   ÚidÚfirstr   Údeleter   )r   r   r   r   r   r   Údelete_mealfood   s   
r$   N)Úfastapir   r   r   Úsqlalchemy.ormr   Údatabaser   Úmodelsr   ÚschemasZMealFoodSchemar   ÚrouterÚgetÚlistÚintr   Úpostr   r#   r$   r   r   r   r   Ú<module>   s     