Merge remote-tracking branch 'origin/conding' into conding

This commit is contained in:
he
2026-09-21 21:40:57 +08:00
12 changed files with 129 additions and 97 deletions
+14 -8
View File
@@ -1,10 +1,10 @@
from fastapi import Query,HTTPException
from pydantic import BaseModel, field_validator
from fastapi import HTTPException
from pydantic import BaseModel, Field,field_validator, model_validator
from datetime import date
from typing import Optional
class EmploymentRequest(BaseModel):
stu_id: int=Query(ge=1)
stu_id: int=Field(ge=1)
email: str|None
employment_opening_date:date
offer_issuance_date:date
@@ -13,11 +13,17 @@ class EmploymentRequest(BaseModel):
salary:float
@field_validator('stu_id')
def check(cls,n):
i = cls.model_dump()
if i['stu_id'] == n:
return n
raise HTTPException(status_code=404,detail='未找到该学生的就业信息!')
@classmethod
def check_stu_id(cls,v):
if v <= 0:
raise ValueError('输入有误,学生ID必须大于0')
return v
@model_validator(mode='after')
def check_date(self):
if self.employment_opening_date > self.offer_issuance_date:
raise ValueError('offer下发日期不能早于就业开放日期')
return self
class EmploymentResponse(BaseModel):
code:int = 200
+17 -1
View File
@@ -1,4 +1,6 @@
from pydantic import BaseModel
from pydantic import BaseModel,Field
from datetime import date
from typing import List, Optional
class AllStuResponse(BaseModel):
class_id: int
@@ -13,3 +15,17 @@ class AvgDayResponse(BaseModel):
class_id: int
avg_days: str | None
class EmpRequest(BaseModel):
stu_id: int
class EmpItem(BaseModel):
stu_id: int
employment_opening_date:date | None
offer_issuance_date:date | None
employment_duration_day: int | None
class AllEmpResponse(BaseModel):
code: int
msg: str
data: List[EmpItem]