Files
DoubaoTeam/schemas/employment.py
T

50 lines
2.1 KiB
Python
Raw Normal View History

2026-09-21 21:29:06 +08:00
from pydantic import BaseModel, Field
from typing import Optional
from datetime import date,datetime
from decimal import Decimal
# int
class EmploymentCreate(BaseModel):
"""新增就业信息 请求体 Schema"""
# 学生ID 必填,一个学生只能有一条就业记录
student_id: int = Field(..., description="关联学生ID,必填")
# 就业状态必填,限定可选值业务枚举
employment_status: str = Field(None, description="就业状态:not_started/job_hunting/offered/employed")
employment_open_date: Optional[date] = Field(None, description="就业开放时间,选填")
offer_date: Optional[date] = Field(None, description="offer下发时间,选填")
company_name: Optional[str] = Field(None, max_length=100, description="就业公司名称,选填")
salary: Optional[Decimal] = Field(None, ge=0, description="就业薪资,不能负数,选填")
remark: Optional[str] = Field(None, max_length=255, description="备注,选填")
class EmploymentUpdate(BaseModel):
"""修改就业信息 请求体 Schema:全部字段可选,只传要修改的字段"""
employment_status: Optional[str] = Field(None, description="就业状态")
employment_open_date: Optional[date] = Field(None, description="就业开放时间")
offer_date: Optional[date] = Field(None, description="offer下发时间")
company_name: Optional[str] = Field(None, max_length=100, description="就业公司名称")
salary: Optional[Decimal] = Field(None, ge=0, description="就业薪资")
remark: Optional[str] = Field(None, max_length=255, description="备注")
class EmploymentResponse(BaseModel):
"""就业信息返回响应体Schema,接口返回给前端的数据结构"""
id: int
student_id: int
employment_status: str
employment_open_date: Optional[date]
offer_date: Optional[date]
company_name: Optional[str]
salary: Optional[Decimal]
remark: Optional[str]
created_at: date
updated_at: date
class Config:
from_attributes = True
class EmploymentListResponse(BaseModel):
total: int
data: list[EmploymentResponse]