"""就业模块出入参(需求 2.3)。""" from __future__ import annotations from datetime import date from pydantic import BaseModel, Field, model_validator from app.schema.common import ORMBase, STRIP_VALIDATOR class _EmploymentBase(BaseModel): open_date: str | None = Field(None, description="就业开放时间 YYYY-MM-DD") offer_date: str | None = Field(None, description="offer 下发时间 YYYY-MM-DD") company: str | None = Field(None, max_length=80, description="就业公司名称") salary: float | None = Field(None, ge=0, description="就业薪资(元/月)") position: str | None = Field(None, max_length=50, description="岗位") city: str | None = Field(None, max_length=30, description="就业城市") remark: str | None = Field(None, description="备注") _v_strip = STRIP_VALIDATOR class EmploymentCreate(_EmploymentBase): stu_id: int = Field(..., description="学生ID(一个学生只能有一条就业记录,重复登记=更新)") @model_validator(mode="after") def _at_least_one(self): if not any([self.open_date, self.offer_date, self.company, self.salary]): raise ValueError("就业开放时间 / offer 时间 / 公司 / 薪资 至少要填一项") return self class EmploymentUpdate(BaseModel): open_date: str | None = None offer_date: str | None = None company: str | None = Field(None, max_length=80) salary: float | None = Field(None, ge=0) position: str | None = None city: str | None = None remark: str | None = None _v_strip = STRIP_VALIDATOR class EmploymentOut(ORMBase): id: int stu_id: int stu_no: str | None = Field(None, description="学号(JOIN 学生表,不落库)") student_name: str | None = Field(None, description="学生姓名(JOIN 学生表,不落库)") class_id: int | None = Field(None, description="班级ID(冗余字段)") class_name: str | None = Field(None, description="班级名称(冗余ID实时取名)") open_date: date | None = None offer_date: date | None = None company: str | None = None salary: float | None = None salary_wan: float | None = Field(None, description="薪资(万元/月)") position: str | None = None city: str | None = None duration_days: int | None = Field(None, description="就业时长(天)= offer 时间 - 开放时间") remark: str | None = None student_status: int | None = Field(None, description="学生当前状态(联动后的结果)") student_status_text: str | None = None class EmploymentRegisterResult(BaseModel): employment: EmploymentOut created: bool = Field(True, description="是新增还是更新已有记录") status_changed: bool = Field(False, description="学生状态是否发生变化") from_status_text: str | None = None to_status_text: str | None = None msg: str = Field("", description="给前端直接展示的一句话")