Update code in endpoints/signup.post.py
This commit is contained in:
parent
57302dd832
commit
5e12c5a0e5
@ -1,30 +1,32 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
|
|
||||||
customers = [] # In-memory storage
|
playlists = [
|
||||||
|
{
|
||||||
|
"id": "playlist1",
|
||||||
|
"songs": [
|
||||||
|
{"id": "song1", "title": "Song One", "artist": "Artist A"},
|
||||||
|
{"id": "song2", "title": "Song Two", "artist": "Artist B"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/signup")
|
@router.post("/playlist/songs")
|
||||||
async def list_customers(
|
async def get_playlist_songs(
|
||||||
store_id: str = "default_store",
|
playlist_id: str = "playlist1"
|
||||||
page: int = 1,
|
|
||||||
limit: int = 10
|
|
||||||
):
|
):
|
||||||
"""Get list of store customers"""
|
"""Fetch songs from a playlist"""
|
||||||
if not any(c["store_id"] == store_id for c in customers):
|
playlist = next((p for p in playlists if p["id"] == playlist_id), None)
|
||||||
raise HTTPException(status_code=400, detail="Store not found")
|
if not playlist:
|
||||||
|
raise HTTPException(status_code=400, detail="Playlist not found")
|
||||||
store_customers = [c for c in customers if c["store_id"] == store_id]
|
|
||||||
start = (page - 1) * limit
|
|
||||||
end = start + limit
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Customers retrieved successfully",
|
"message": "Songs fetched successfully",
|
||||||
"store_id": store_id,
|
"playlist_id": playlist_id,
|
||||||
"customers": store_customers[start:end],
|
"songs": playlist["songs"],
|
||||||
"pagination": {
|
"features": {
|
||||||
"page": page,
|
"total_songs": len(playlist["songs"]),
|
||||||
"total": len(store_customers),
|
"can_shuffle": True
|
||||||
"pages": (len(store_customers) + limit - 1) // limit
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user