Add review model and CRUD endpoints for managing song reviews

This commit is contained in:
Esa Kataja
2025-05-05 18:32:39 +03:00
parent bf7c969629
commit e647bc7811
2 changed files with 107 additions and 2 deletions
+41
View File
@@ -0,0 +1,41 @@
from pydantic import BaseModel, Field
from datetime import datetime
class ReviewBase(BaseModel):
song_id: int = Field(description="ID of the song", examples=[1])
user_id: int = Field(description="ID of the user", examples=[1])
score_song: int = Field(
gt=0, le=100, description="Score given by the user", examples=[1]
)
score_show: int = Field(
gt=0, le=100, description="Score given by the user", examples=[1]
)
score_costume: int = Field(
gt=0, le=100, description="Score given by the user", examples=[1]
)
text_review: str | None = Field(
default=None, description="Comment given by the user", examples=["comment"]
)
class ReviewIn(ReviewBase):
pass
class ReviewSearch(BaseModel):
song_id: int = Field(description="ID of the song", examples=[1])
user_id: int = Field(description="ID of the user", examples=[1])
class ReviewOut(ReviewBase):
created_at: datetime = Field(
default_factory=datetime.now,
description="Creation timestamp",
examples=["2025-01-01T00:00:00.000Z"],
)
updated_at: datetime = Field(
default_factory=datetime.now,
description="Last update timestamp",
examples=["2025-01-01T00:00:00.000Z"],
)