修改schema
This commit is contained in:
@@ -2,7 +2,7 @@ from pydantic import BaseModel, Field, 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"])
|
||||
@@ -40,6 +40,15 @@ class ConstructionResponse(BaseResponseWithID):
|
||||
# 2025-10-20新增字段,延迟时间
|
||||
delay_days: Optional[int] = Field(None, description="延迟时间(天)", examples=[0])
|
||||
|
||||
@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_complete_date,
|
||||
)
|
||||
return self
|
||||
|
||||
class ConstructionCreate(BaseModel):
|
||||
"""
|
||||
施工任务创建模型
|
||||
|
||||
Reference in New Issue
Block a user