68 lines
2.5 KiB
Python
68 lines
2.5 KiB
Python
# scheme/employment.py
|
|||
|
|
# 就业模块的请求/响应模型
|
||
|
|
from datetime import date
|
||
|
|
from typing import List, Optional
|
||
|
|
|
||
|
|
from pydantic import BaseModel, Field
|
||
|
|
|
||
|
|
|
||
|
|
# -------------------- 请求体模型 -----------------------------
|
||
|
|
class EmploymentOpen(BaseModel):
|
||
|
|
"""登记就业开放(开放简历):学生状态联动更新为『进入就业』"""
|
||
|
|
stu_id: int = Field(..., ge=1, description="学生编号")
|
||
|
|
employment_open_time: date = Field(..., description="就业开放时间")
|
||
|
|
|
||
|
|
|
||
|
|
class OfferAdd(BaseModel):
|
||
|
|
"""登记 offer:插入 offer 记录 + 更新就业基础表 + 学生状态联动更新为『已就业』"""
|
||
|
|
stu_id: int = Field(..., ge=1, description="学生编号")
|
||
|
|
offer_time: date = Field(..., description="offer 下发时间")
|
||
|
|
company_name: str = Field(..., min_length=1, max_length=100, description="就业公司名称")
|
||
|
|
salary: float = Field(..., ge=0, description="就业薪资")
|
||
|
|
|
||
|
|
|
||
|
|
class EmploymentUpdate(BaseModel):
|
||
|
|
"""修改就业基础信息"""
|
||
|
|
company_name: Optional[str] = Field(None, min_length=1, max_length=100, description="公司名称")
|
||
|
|
salary: Optional[float] = Field(None, ge=0, description="薪资")
|
||
|
|
job_time: Optional[date] = Field(None, description="offer 下发时间")
|
||
|
|
employment_open_time: Optional[date] = Field(None, description="就业开放时间")
|
||
|
|
|
||
|
|
|
||
|
|
class OfferUpdate(BaseModel):
|
||
|
|
"""修改某条 offer"""
|
||
|
|
offer_time: Optional[date] = Field(None, description="offer 下发时间")
|
||
|
|
company_name: Optional[str] = Field(None, min_length=1, max_length=100, description="公司名")
|
||
|
|
salary: Optional[float] = Field(None, ge=0, description="薪资")
|
||
|
|
|
||
|
|
|
||
|
|
# -------------------- 响应模型 ----------------------------
|
||
|
|
class OfferResponse(BaseModel):
|
||
|
|
stu_id: int
|
||
|
|
offer_id: int
|
||
|
|
offer_time: date
|
||
|
|
company_name: Optional[str] = None
|
||
|
|
salary: Optional[float] = None
|
||
|
|
|
||
|
|
class Config:
|
||
|
|
from_attributes = True
|
||
|
|
|
||
|
|
|
||
|
|
class EmploymentResponse(BaseModel):
|
||
|
|
stu_id: int
|
||
|
|
stu_name: str = Field(..., description="学生姓名(冗余字段)")
|
||
|
|
class_name: str = Field(..., description="学生班级(冗余字段)")
|
||
|
|
employment_open_time: date
|
||
|
|
job_time: Optional[date] = None
|
||
|
|
company_name: Optional[str] = None
|
||
|
|
salary: Optional[float] = None
|
||
|
|
offers: List[OfferResponse] = Field(default_factory=list, description="该学生的全部 offer 记录")
|
||
|
|
|
||
|
|
class Config:
|
||
|
|
from_attributes = True
|
||
|
|
|
||
|
|
|
||
|
|
class EmploymentListResponse(BaseModel):
|
||
|
|
total: int
|
||
|
|
items: List[EmploymentResponse]
|