2026-09-21 20:18:52 +08:00
|
|
|
from pydantic import BaseModel, Field,field_validator, model_validator
|
2026-09-21 16:48:27 +08:00
|
|
|
from datetime import date
|
|
|
|
|
from typing import Optional
|
2026-09-21 14:13:23 +08:00
|
|
|
|
2026-09-21 18:02:12 +08:00
|
|
|
class EmploymentRequest(BaseModel):
|
2026-09-22 11:31:37 +08:00
|
|
|
stu_id: int=Field(ge=1,description='学生编号')
|
|
|
|
|
email: Optional[str] = Field(None, description='邮箱')
|
|
|
|
|
employment_opening_date:Optional[date] = Field(None, description='就业开放日期')
|
2026-09-22 14:36:43 +08:00
|
|
|
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='就业开放日期')
|
2026-09-22 11:31:37 +08:00
|
|
|
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='薪资')
|
2026-09-21 20:18:52 +08:00
|
|
|
|
|
|
|
|
@model_validator(mode='after')
|
|
|
|
|
def check_date(self):
|
2026-09-22 10:41:26 +08:00
|
|
|
if self.employment_opening_date and self.offer_issuance_date:
|
|
|
|
|
if self.employment_opening_date > self.offer_issuance_date:
|
|
|
|
|
raise ValueError('offer下发日期不能早于就业开放日期')
|
2026-09-21 20:18:52 +08:00
|
|
|
return self
|
2026-09-21 14:13:23 +08:00
|
|
|
|
|
|
|
|
class EmploymentResponse(BaseModel):
|
|
|
|
|
code:int = 200
|
|
|
|
|
detail:str = 'OK'
|
2026-09-22 11:31:37 +08:00
|
|
|
emp_id: int
|
2026-09-22 10:41:26 +08:00
|
|
|
stu_id:int
|
2026-09-22 11:31:37 +08:00
|
|
|
stu_name: Optional[str] = None
|
|
|
|
|
class_id: Optional[int] = None
|
2026-09-22 10:41:26 +08:00
|
|
|
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
|