Files
test/app/schema/advisor_schema.py
T

49 lines
1.5 KiB
Python
Raw Normal View History

2026-09-21 19:03:31 +08:00
"""顾问模块出入参(需求第 5 节扩展模块)。"""
from __future__ import annotations
from pydantic import BaseModel, Field
from app.schema.common import GENDER_VALIDATOR, ORMBase, STRIP_VALIDATOR
class _AdvisorBase(BaseModel):
name: str = Field(..., min_length=1, max_length=30, description="顾问姓名")
gender: int = Field(1, description="性别 1=男 2=女")
phone: str | None = Field(None, max_length=20, description="联系电话")
email: str | None = Field(None, max_length=60, description="邮箱")
dept: str | None = Field(None, max_length=50, description="所属部门")
remark: str | None = Field(None, max_length=255, description="备注")
_v_gender = GENDER_VALIDATOR
_v_strip = STRIP_VALIDATOR
class AdvisorCreate(_AdvisorBase):
advisor_no: str | None = Field(None, max_length=20, description="顾问编号,不传自动生成 A+序号")
class AdvisorUpdate(BaseModel):
name: str | None = Field(None, min_length=1, max_length=30)
gender: int | None = None
phone: str | None = None
email: str | None = None
dept: str | None = None
remark: str | None = None
_v_gender = GENDER_VALIDATOR
_v_strip = STRIP_VALIDATOR
class AdvisorOut(ORMBase):
id: int
advisor_no: str
name: str
gender: int
gender_text: str | None = None
phone: str | None = None
email: str | None = None
dept: str | None = None
remark: str | None = None
student_count: int = Field(0, description="名下学生数(详情接口填充)")