Files
SST/PythonProject/schema/employment_schema.py
T

32 lines
1.0 KiB
Python
Raw Normal View History

2026-09-21 20:18:52 +08:00
from fastapi import HTTPException
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-21 20:18:52 +08:00
stu_id: int=Field(ge=1)
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
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 10:41:26 +08:00
stu_id:int
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