58 lines
2.1 KiB
Python
58 lines
2.1 KiB
Python
from pydantic import BaseModel, Field
|
|
|
|
from app.enums.team import TeamStatus
|
|
from app.schemas.common import NaiveDatetime, NaiveDatetimeOptional
|
|
|
|
|
|
class TeamBase(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=128, description="团队名称")
|
|
code: str | None = Field(None, max_length=64, description="团队编码,可选,建议用于内部标识")
|
|
description: str | None = Field(None, max_length=512, description="团队备注")
|
|
status: str = Field(default=TeamStatus.ACTIVE.value, pattern="^(active|disabled)$", description="团队状态:active启用,disabled禁用")
|
|
sort_order: int = Field(default=0, ge=0, le=999999, description="排序值,越小越靠前")
|
|
|
|
|
|
class TeamCreate(TeamBase):
|
|
pass
|
|
|
|
|
|
class TeamUpdate(BaseModel):
|
|
name: str = Field(..., min_length=1, max_length=128, description="团队名称")
|
|
code: str | None = Field(None, max_length=64, description="团队编码,可选,建议用于内部标识")
|
|
description: str | None = Field(None, max_length=512, description="团队备注")
|
|
status: str = Field(default=TeamStatus.ACTIVE.value, pattern="^(active|disabled)$", description="团队状态:active启用,disabled禁用")
|
|
sort_order: int = Field(default=0, ge=0, le=999999, description="排序值,越小越靠前")
|
|
|
|
|
|
class TeamOut(TeamBase):
|
|
id: str
|
|
status_label: str = ""
|
|
is_read_only: bool = False
|
|
team_credit_frozen: bool = False
|
|
member_count: int = 0
|
|
created_at: NaiveDatetime
|
|
updated_at: NaiveDatetimeOptional = None
|
|
manager_id: str | None = None
|
|
manager_name: str | None = None
|
|
first_subscription_paid_at: NaiveDatetimeOptional = None
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class TeamOptionOut(BaseModel):
|
|
id: str
|
|
name: str
|
|
code: str | None = None
|
|
status: str = TeamStatus.ACTIVE.value
|
|
|
|
model_config = {"from_attributes": True}
|
|
|
|
|
|
class TeamListOut(BaseModel):
|
|
items: list[TeamOut]
|
|
total: int
|
|
|
|
|
|
class UpdateUserTeamRequest(BaseModel):
|
|
team_id: str | None = Field(None, description="团队ID;传 null 表示取消团队归属")
|