31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""修改范围及后续能力需求"""
|
|
|
|
from typing import Literal, Self
|
|
|
|
from pydantic import Field, model_validator
|
|
|
|
from app.schemas.base import ExtensibleModel, NonBlankString
|
|
|
|
|
|
class ChangeScope(ExtensibleModel):
|
|
scope: Literal["local", "screen"] = Field(
|
|
description="local=局部修改或新增;screen=整体设计或修改"
|
|
)
|
|
target_ids: list[NonBlankString] = Field(
|
|
default_factory=list, description="涉及的已有组件 ID,新增内容和画布属性可为空"
|
|
)
|
|
needs_planning: bool = Field(
|
|
description="是否需要布局、组件组合或设计规划,与范围大小分别判断"
|
|
)
|
|
resource_needs: list[NonBlankString] = Field(
|
|
default_factory=list,
|
|
description="需要补充查询的数据、组件、模板或素材及用途,已有信息足够则为空",
|
|
)
|
|
reason: NonBlankString = Field(description="简短说明范围、规划和资源判断依据")
|
|
|
|
@model_validator(mode="after")
|
|
def unique_targets(self) -> Self:
|
|
if len(self.target_ids) != len(set(self.target_ids)):
|
|
raise ValueError("target_ids 不能包含重复 ID")
|
|
return self
|