feat: Implement favorites management API; add endpoints for adding, removing, and retrieving favorites for sounds and playlists
feat: Create Favorite model and repository for managing user favorites in the database feat: Add FavoriteService to handle business logic for favorites management feat: Enhance Playlist and Sound response schemas to include favorite indicators and counts refactor: Update API routes to include favorites functionality in playlists and sounds
This commit is contained in:
39
app/schemas/favorite.py
Normal file
39
app/schemas/favorite.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Favorite response schemas."""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class FavoriteResponse(BaseModel):
|
||||
"""Response schema for a favorite."""
|
||||
|
||||
id: int = Field(description="Favorite ID")
|
||||
user_id: int = Field(description="User ID")
|
||||
sound_id: int | None = Field(
|
||||
description="Sound ID if this is a sound favorite", default=None
|
||||
)
|
||||
playlist_id: int | None = Field(
|
||||
description="Playlist ID if this is a playlist favorite", default=None
|
||||
)
|
||||
created_at: datetime = Field(description="Creation timestamp")
|
||||
updated_at: datetime = Field(description="Last update timestamp")
|
||||
|
||||
class Config:
|
||||
"""Pydantic config."""
|
||||
|
||||
from_attributes = True
|
||||
|
||||
|
||||
class FavoritesListResponse(BaseModel):
|
||||
"""Response schema for a list of favorites."""
|
||||
|
||||
favorites: list[FavoriteResponse] = Field(description="List of favorites")
|
||||
|
||||
|
||||
class FavoriteCountsResponse(BaseModel):
|
||||
"""Response schema for favorite counts."""
|
||||
|
||||
total: int = Field(description="Total number of favorites")
|
||||
sounds: int = Field(description="Number of favorited sounds")
|
||||
playlists: int = Field(description="Number of favorited playlists")
|
||||
Reference in New Issue
Block a user