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