Add Glory schema

This commit is contained in:
Backend IM Bot 2025-03-27 21:25:46 +00:00
parent a92196324d
commit a31c341d76

View File

@ -2,21 +2,19 @@ from pydantic import BaseModel, Field
from typing import Optional from typing import Optional
class GloryBase(BaseModel): class GloryBase(BaseModel):
team_name: str = Field(..., description="Team name", index=True) team_name: str = Field(..., min_length=1, max_length=100)
league: str = Field(..., description="League name") league: str = Field(..., min_length=1, max_length=100)
points: int = Field(default=0, description="Total points") points: int = Field(default=0, ge=0)
matches_played: int = Field(default=0, description="Number of matches played") matches_played: int = Field(default=0, ge=0)
wins: int = Field(default=0, description="Number of wins") wins: int = Field(default=0, ge=0)
draws: int = Field(default=0, description="Number of draws") draws: int = Field(default=0, ge=0)
losses: int = Field(default=0, description="Number of losses") losses: int = Field(default=0, ge=0)
goals_for: int = Field(default=0, description="Goals scored") goals_for: int = Field(default=0, ge=0)
goals_against: int = Field(default=0, description="Goals conceded") goals_against: int = Field(default=0, ge=0)
goal_difference: int = Field(default=0, description="Goal difference") goal_difference: int = Field(default=0)
position: int = Field(..., description="Current position in league") position: int = Field(..., gt=0)
is_active: bool = Field(default=True, description="Team active status") is_active: bool = Field(default=True)
season: str = Field(..., description="Season identifier") season: str = Field(..., min_length=1, max_length=50)
coach: Optional[str] = Field(None, description="Team coach name")
home_stadium: Optional[str] = Field(None, description="Home stadium name")
class GloryCreate(GloryBase): class GloryCreate(GloryBase):
class Config: class Config:
@ -25,17 +23,18 @@ class GloryCreate(GloryBase):
"team_name": "Manchester United", "team_name": "Manchester United",
"league": "Premier League", "league": "Premier League",
"position": 1, "position": 1,
"season": "2023/2024", "season": "2023/2024"
"coach": "Erik ten Hag",
"home_stadium": "Old Trafford"
} }
} }
class Glory(GloryBase): class Glory(GloryBase):
id: int = Field(..., gt=0)
class Config: class Config:
orm_mode = True orm_mode = True
schema_extra = { schema_extra = {
"example": { "example": {
"id": 1,
"team_name": "Manchester United", "team_name": "Manchester United",
"league": "Premier League", "league": "Premier League",
"points": 75, "points": 75,
@ -48,8 +47,6 @@ class Glory(GloryBase):
"goal_difference": 32, "goal_difference": 32,
"position": 1, "position": 1,
"is_active": True, "is_active": True,
"season": "2023/2024", "season": "2023/2024"
"coach": "Erik ten Hag",
"home_stadium": "Old Trafford"
} }
} }