39 lines
847 B
Python
39 lines
847 B
Python
from pydantic import BaseModel, ConfigDict
|
|
from typing import Optional, List
|
|
from datetime import datetime
|
|
|
|
# Base schema with common attributes
|
|
class GameBase(BaseModel):
|
|
name: str
|
|
description: str
|
|
image_url: str
|
|
|
|
# Schema for creating a new game
|
|
class GameCreate(GameBase):
|
|
pass
|
|
|
|
# Schema for updating a game
|
|
class GameUpdate(BaseModel):
|
|
name: Optional[str] = None
|
|
description: Optional[str] = None
|
|
image_url: Optional[str] = None
|
|
|
|
# Schema for reading a game
|
|
class Game(GameBase):
|
|
id: int
|
|
created_at: datetime
|
|
updated_at: datetime
|
|
boxes: List["Box"] = []
|
|
|
|
model_config = ConfigDict(from_attributes=True)
|
|
|
|
# Schema for deleting a game
|
|
class GameDelete(BaseModel):
|
|
id: int
|
|
|
|
# Schema for listing games
|
|
class GameList(BaseModel):
|
|
games: List[Game]
|
|
total: int
|
|
page: int
|
|
limit: int |