Files
SST/PythonProject/schema/employment_schema.py
T
2026-09-22 14:36:43 +08:00

49 lines
2.1 KiB
Python

from pydantic import BaseModel, Field,field_validator, model_validator
from datetime import date
from typing import Optional
class EmploymentRequest(BaseModel):
stu_id: int=Field(ge=1,description='学生编号')
email: Optional[str] = Field(None, description='邮箱')
employment_opening_date:Optional[date] = Field(None, description='就业开放日期')
offer_issuance_date:Optional[date] = Field(None, description='offer下发日期')
company_name:Optional[str] = Field(None, description='公司名称')
company_address:Optional[str] = Field(None, description='公司地址')
salary:Optional[float] = Field(None, description='薪资')
@model_validator(mode='after')
def check_date(self):
if self.employment_opening_date and self.offer_issuance_date:
if self.employment_opening_date > self.offer_issuance_date:
raise ValueError('offer下发日期不能早于就业开放日期')
return self
class UpdateEmpRequest(BaseModel):
email: Optional[str] = Field(None, description='邮箱')
employment_opening_date:Optional[date] = Field(None, description='就业开放日期')
offer_issuance_date:Optional[date] = Field(None, description='offer下发日期')
company_name:Optional[str] = Field(None, description='公司名称')
company_address:Optional[str] = Field(None, description='公司地址')
salary:Optional[float] = Field(None, description='薪资')
@model_validator(mode='after')
def check_date(self):
if self.employment_opening_date and self.offer_issuance_date:
if self.employment_opening_date > self.offer_issuance_date:
raise ValueError('offer下发日期不能早于就业开放日期')
return self
class EmploymentResponse(BaseModel):
code:int = 200
detail:str = 'OK'
emp_id: int
stu_id:int
stu_name: Optional[str] = None
class_id: Optional[int] = None
email: str|None = None
employment_opening_date:date|None = None
offer_issuance_date:date|None = None
company_name:str|None = None
company_address:str|None = None
salary:float|None = None