Files
wo_chovy/schema/employment_schema.py
2026-09-21 19:49:26 +08:00

44 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# path: schema/employment_schema.py
# time:2026年9月12日10:30
# title:就业信息,请求模型、响应模型
# author:周兴
# info:定义API接收的数据、返回的数据的格式,通过Pydantic做数据校验
from pydantic import BaseModel, Field, ConfigDict
from datetime import datetime
# 新增就业信息 请求模型
class EmploymentCreate(BaseModel):
# 学生ID,新增就业信息时必须指定学生
student_id: int
# 就业开放时间
employment_start_time: datetime | None = None
# offer下发时间
offer_time: datetime | None = None
# 就业公司名称
company_name: str | None = None
# 就业薪资,不能小于0
salary: float | None = Field(default=None, ge=0)
# 修改就业信息 请求模型
class EmploymentUpdate(BaseModel):
# 修改时所有字段都可以不传
employment_start_time: datetime | None = None
offer_time: datetime | None = None
company_name: str | None = None
salary: float | None = Field(default=None, ge=0)
# 就业信息 响应模型
# API返回给用户的数据格式
class EmploymentResponse(BaseModel):
id: int
student_id: int
employment_start_time: datetime | None = None
offer_time: datetime | None = None
company_name: str | None = None
salary: float | None = None
flag: int
# 允许 Pydantic 读取 SQLAlchemy ORM 对象
model_config = ConfigDict(from_attributes=True)