claude_sms_test
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
# schemas/__init__.py
|
||||
# 聚合入口:统一导出所有 Pydantic 模式(请求体校验 & 响应序列化),方便外部导入
|
||||
|
||||
from schemas.stu_schema import StuInfoCreate, StuInfoUpdate, StuInfoOut
|
||||
from schemas.stu_score_schema import StuScoreCreate, StuScoreUpdate, StuScoreOut
|
||||
from schemas.cls_mgmt_schema import ClsMgmtCreate, ClsMgmtUpdate, ClsMgmtOut
|
||||
from schemas.employ_schema import EmployCreate, EmployUpdate, EmployOut
|
||||
from schemas.teacher_schema import TeacherCreate, TeacherUpdate, TeacherOut
|
||||
from schemas.advisor_schema import AdvisorCreate, AdvisorUpdate, AdvisorOut
|
||||
|
||||
__all__ = [
|
||||
"StuInfoCreate", "StuInfoUpdate", "StuInfoOut",
|
||||
"StuScoreCreate", "StuScoreUpdate", "StuScoreOut",
|
||||
"ClsMgmtCreate", "ClsMgmtUpdate", "ClsMgmtOut",
|
||||
"EmployCreate", "EmployUpdate", "EmployOut",
|
||||
"TeacherCreate", "TeacherUpdate", "TeacherOut",
|
||||
"AdvisorCreate", "AdvisorUpdate", "AdvisorOut",
|
||||
]
|
||||
@@ -0,0 +1,31 @@
|
||||
# schemas/advisor_schema.py
|
||||
# 顾问信息模块的 Pydantic 模式
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class AdvisorBase(BaseModel):
|
||||
"""顾问公共字段"""
|
||||
name: str = Field(..., max_length=20, description="姓名")
|
||||
phone: str = Field(..., max_length=20, description="电话")
|
||||
|
||||
|
||||
class AdvisorCreate(AdvisorBase):
|
||||
"""新增顾问时,id 必填"""
|
||||
id: str = Field(..., max_length=15, description="顾问编号(主键)")
|
||||
|
||||
|
||||
class AdvisorUpdate(BaseModel):
|
||||
"""更新顾问信息:仅更新传入的字段"""
|
||||
name: Optional[str] = Field(default=None, max_length=20, description="姓名")
|
||||
phone: Optional[str] = Field(default=None, max_length=20, description="电话")
|
||||
|
||||
|
||||
class AdvisorOut(AdvisorBase):
|
||||
"""顾问响应模型(含 id 与软删除标记)"""
|
||||
id: str
|
||||
is_deleted: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,34 @@
|
||||
# schemas/cls_mgmt_schema.py
|
||||
# 班级管理模块的 Pydantic 模式
|
||||
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class ClsMgmtBase(BaseModel):
|
||||
"""班级公共字段"""
|
||||
cls_start_date: date = Field(..., description="开课时间")
|
||||
head_tea_id: str = Field(..., max_length=15, description="班主任id")
|
||||
lecturer_id: str = Field(..., max_length=15, description="主讲老师id")
|
||||
|
||||
|
||||
class ClsMgmtCreate(ClsMgmtBase):
|
||||
"""新增班级时,id(班级编号)必填"""
|
||||
id: str = Field(..., max_length=15, description="班级编号(主键)")
|
||||
|
||||
|
||||
class ClsMgmtUpdate(BaseModel):
|
||||
"""更新班级信息:仅更新传入的字段"""
|
||||
cls_start_date: Optional[date] = Field(default=None, description="开课时间")
|
||||
head_tea_id: Optional[str] = Field(default=None, max_length=15, description="班主任id")
|
||||
lecturer_id: Optional[str] = Field(default=None, max_length=15, description="主讲老师id")
|
||||
|
||||
|
||||
class ClsMgmtOut(ClsMgmtBase):
|
||||
"""班级响应模型(含 id 与软删除标记)"""
|
||||
id: str
|
||||
is_deleted: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,37 @@
|
||||
# schemas/employ_schema.py
|
||||
# 学生就业管理模块的 Pydantic 模式
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class EmployBase(BaseModel):
|
||||
"""就业信息公共字段"""
|
||||
emp_open_time: Optional[date] = Field(default=None, description="就业开放时间")
|
||||
send_offer_time: Optional[date] = Field(default=None, description="收到Offer时间")
|
||||
emp_company: Optional[str] = Field(default=None, max_length=50, description="就业公司名称")
|
||||
salary: Optional[Decimal] = Field(default=None, ge=0, description="薪资(月薪/元)")
|
||||
|
||||
|
||||
class EmployCreate(EmployBase):
|
||||
"""新增就业记录时,stu_id 必填(与学生一对一)"""
|
||||
stu_id: str = Field(..., max_length=15, description="学生编号(主键)")
|
||||
|
||||
|
||||
class EmployUpdate(BaseModel):
|
||||
"""更新就业信息:仅更新传入的字段"""
|
||||
emp_open_time: Optional[date] = Field(default=None, description="就业开放时间")
|
||||
send_offer_time: Optional[date] = Field(default=None, description="收到Offer时间")
|
||||
emp_company: Optional[str] = Field(default=None, max_length=50, description="就业公司名称")
|
||||
salary: Optional[Decimal] = Field(default=None, ge=0, description="薪资(月薪/元)")
|
||||
|
||||
|
||||
class EmployOut(EmployBase):
|
||||
"""就业响应模型(含 stu_id 与软删除标记)"""
|
||||
stu_id: str
|
||||
is_deleted: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,52 @@
|
||||
# schemas/stu_schema.py
|
||||
# 学生信息模块的 Pydantic 模式:请求体校验 & 响应序列化
|
||||
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class StuInfoBase(BaseModel):
|
||||
"""学生信息公共字段"""
|
||||
cls_id: str = Field(..., max_length=15, description="所属班级编号")
|
||||
name: str = Field(..., max_length=20, description="姓名")
|
||||
gender: Optional[str] = Field(default="男", max_length=1, description="性别")
|
||||
age: Optional[int] = Field(default=None, ge=0, description="年龄")
|
||||
hometown: Optional[str] = Field(default=None, max_length=50, description="籍贯")
|
||||
grad_school: Optional[str] = Field(default=None, max_length=50, description="毕业院校")
|
||||
major: Optional[str] = Field(default=None, max_length=50, description="专业")
|
||||
education: Optional[str] = Field(default=None, max_length=20, description="学历")
|
||||
enr_date: Optional[date] = Field(default=None, description="入学日期")
|
||||
grad_date: Optional[date] = Field(default=None, description="毕业日期")
|
||||
advisor_id: Optional[str] = Field(default=None, max_length=15, description="顾问编号")
|
||||
state: Optional[str] = Field(default="在读", max_length=10, description="状态")
|
||||
|
||||
|
||||
class StuInfoCreate(StuInfoBase):
|
||||
"""新增学生时,id(学号)必填"""
|
||||
id: str = Field(..., max_length=15, description="学生编号(主键)")
|
||||
|
||||
|
||||
class StuInfoUpdate(BaseModel):
|
||||
"""更新学生信息:所有字段均可选,仅更新传入的字段"""
|
||||
cls_id: Optional[str] = Field(default=None, max_length=15, description="所属班级编号")
|
||||
name: Optional[str] = Field(default=None, max_length=20, description="姓名")
|
||||
gender: Optional[str] = Field(default=None, max_length=1, description="性别")
|
||||
age: Optional[int] = Field(default=None, ge=0, description="年龄")
|
||||
hometown: Optional[str] = Field(default=None, max_length=50, description="籍贯")
|
||||
grad_school: Optional[str] = Field(default=None, max_length=50, description="毕业院校")
|
||||
major: Optional[str] = Field(default=None, max_length=50, description="专业")
|
||||
education: Optional[str] = Field(default=None, max_length=20, description="学历")
|
||||
enr_date: Optional[date] = Field(default=None, description="入学日期")
|
||||
grad_date: Optional[date] = Field(default=None, description="毕业日期")
|
||||
advisor_id: Optional[str] = Field(default=None, max_length=15, description="顾问编号")
|
||||
state: Optional[str] = Field(default=None, max_length=10, description="状态")
|
||||
|
||||
|
||||
class StuInfoOut(StuInfoBase):
|
||||
"""学生信息响应模型(含 id 与软删除标记)"""
|
||||
id: str
|
||||
is_deleted: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,36 @@
|
||||
# schemas/stu_score_schema.py
|
||||
# 学生成绩模块的 Pydantic 模式
|
||||
|
||||
from decimal import Decimal
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class StuScoreBase(BaseModel):
|
||||
"""成绩公共字段"""
|
||||
stu_id: str = Field(..., max_length=15, description="学生编号")
|
||||
exam_attempt: int = Field(default=1, ge=1, description="考试轮次")
|
||||
exam_score: Decimal = Field(..., ge=0, le=100, description="成绩(0-100)")
|
||||
score_level: Optional[str] = Field(default=None, max_length=10, description="成绩等级")
|
||||
|
||||
|
||||
class StuScoreCreate(StuScoreBase):
|
||||
"""新增成绩记录"""
|
||||
pass
|
||||
|
||||
|
||||
class StuScoreUpdate(BaseModel):
|
||||
"""更新成绩记录:仅更新传入的字段"""
|
||||
stu_id: Optional[str] = Field(default=None, max_length=15, description="学生编号")
|
||||
exam_attempt: Optional[int] = Field(default=None, ge=1, description="考试轮次")
|
||||
exam_score: Optional[Decimal] = Field(default=None, ge=0, le=100, description="成绩(0-100)")
|
||||
score_level: Optional[str] = Field(default=None, max_length=10, description="成绩等级")
|
||||
|
||||
|
||||
class StuScoreOut(StuScoreBase):
|
||||
"""成绩响应模型(含自增 id 与软删除标记)"""
|
||||
id: int
|
||||
is_deleted: bool
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
@@ -0,0 +1,33 @@
|
||||
# schemas/teacher_schema.py
|
||||
# 教师信息模块的 Pydantic 模式
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class TeacherBase(BaseModel):
|
||||
"""教师公共字段"""
|
||||
name: str = Field(..., max_length=20, description="姓名")
|
||||
phone: str = Field(..., max_length=20, description="电话(唯一)")
|
||||
type: str = Field(..., max_length=20, description="教师职位")
|
||||
|
||||
|
||||
class TeacherCreate(TeacherBase):
|
||||
"""新增教师时,id 必填"""
|
||||
id: str = Field(..., max_length=15, description="教师编号(主键)")
|
||||
|
||||
|
||||
class TeacherUpdate(BaseModel):
|
||||
"""更新教师信息:仅更新传入的字段"""
|
||||
name: Optional[str] = Field(default=None, max_length=20, description="姓名")
|
||||
phone: Optional[str] = Field(default=None, max_length=20, description="电话(唯一)")
|
||||
type: Optional[str] = Field(default=None, max_length=20, description="教师职位")
|
||||
|
||||
|
||||
class TeacherOut(TeacherBase):
|
||||
"""教师响应模型(含 id 与软删除标记)"""
|
||||
id: str
|
||||
is_deleted: int
|
||||
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
Reference in New Issue
Block a user