修改schema
This commit is contained in:
+10
-1
@@ -2,7 +2,7 @@ from pydantic import Field, BaseModel,field_validator,model_validator
|
||||
from fastapi import HTTPException
|
||||
from typing import List, Optional, Literal
|
||||
from ..common.validators import DateStr
|
||||
from ..common.base import BaseResponseWithID
|
||||
from ..common.base import BaseResponseWithID, trim_plan_nodes_by_boundary_dates
|
||||
|
||||
class PlanNode(BaseModel):
|
||||
date: DateStr = Field(..., description="计划节点时间", examples=["2024-01-01"])
|
||||
@@ -61,6 +61,15 @@ class PowerResponse(BaseResponseWithID):
|
||||
None, description="实际首批到场人数", examples=[4]
|
||||
)
|
||||
|
||||
@model_validator(mode='after')
|
||||
def clean_response_plan_nodes(self):
|
||||
self.plan_node = trim_plan_nodes_by_boundary_dates(
|
||||
self.plan_node,
|
||||
start_date=self.plan_start_date,
|
||||
end_date=self.plan_exit_date,
|
||||
)
|
||||
return self
|
||||
|
||||
class PowerCreate(BaseModel):
|
||||
"""
|
||||
创建力能
|
||||
|
||||
Reference in New Issue
Block a user