就业get次昂管的dao层和api接口
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user