Update code in endpoints/playlist.get.py
This commit is contained in:
parent
e86868fdde
commit
f673f235fd
@ -1,19 +1,23 @@
|
|||||||
# Entity: Playlist
|
# Entity: Meal
|
||||||
|
|
||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
from typing import List
|
from typing import List
|
||||||
from core.database import get_db
|
from core.database import get_db
|
||||||
from models.playlist import Playlist
|
from models.meal import Meal
|
||||||
from schemas.playlist import PlaylistSchema
|
from schemas.meal import MealSchema
|
||||||
from helpers.playlist_helpers import get_playlist_songs
|
from helpers.meal_helpers import get_all_meals, get_meals_by_category
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.get("/playlist", response_model=List[PlaylistSchema], status_code=200)
|
@router.get("/meals", status_code=200, response_model=List[MealSchema])
|
||||||
async def get_playlist_songs(
|
async def get_meals(
|
||||||
|
category: str = None,
|
||||||
db: Session = Depends(get_db)
|
db: Session = Depends(get_db)
|
||||||
):
|
):
|
||||||
"""Get all songs from playlist"""
|
"""Get all meals with optional category filter"""
|
||||||
songs = get_playlist_songs(db)
|
if category:
|
||||||
return songs
|
meals = get_meals_by_category(db, category)
|
||||||
|
else:
|
||||||
|
meals = get_all_meals(db)
|
||||||
|
return meals
|
Loading…
x
Reference in New Issue
Block a user