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