Files
Eurovision-25-backend/src/models/review.py
T

42 lines
1.2 KiB
Python

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"],
)