修改schema
This commit is contained in:
@@ -59,6 +59,39 @@ class BaseResponseWithID(BaseModel):
|
||||
# 默认返回(已有 id)
|
||||
return data
|
||||
|
||||
|
||||
def _get_plan_node_date(node: Any) -> Any:
|
||||
if isinstance(node, dict):
|
||||
return node.get("date")
|
||||
return getattr(node, "date", None)
|
||||
|
||||
|
||||
def trim_plan_nodes_by_boundary_dates(
|
||||
plan_nodes: Optional[List[Any]],
|
||||
start_date: Optional[Any] = None,
|
||||
end_date: Optional[Any] = None,
|
||||
) -> List[Any]:
|
||||
if not plan_nodes:
|
||||
return []
|
||||
|
||||
cleaned_nodes = list(plan_nodes)
|
||||
|
||||
while (
|
||||
start_date is not None
|
||||
and cleaned_nodes
|
||||
and str(_get_plan_node_date(cleaned_nodes[0])) == str(start_date)
|
||||
):
|
||||
cleaned_nodes.pop(0)
|
||||
|
||||
while (
|
||||
end_date is not None
|
||||
and cleaned_nodes
|
||||
and str(_get_plan_node_date(cleaned_nodes[-1])) == str(end_date)
|
||||
):
|
||||
cleaned_nodes.pop()
|
||||
|
||||
return cleaned_nodes
|
||||
|
||||
class RequestApprovalMixin(BaseModel):
|
||||
"""
|
||||
请求审批相关的基础模型
|
||||
|
||||
Reference in New Issue
Block a user