feat: 实现受控真实下单安全边界 (#99)
This commit is contained in:
@@ -56,8 +56,8 @@ class ClaimCapabilities:
|
||||
raise ValueError("supported_types 不能为空")
|
||||
if any(not isinstance(value, TaskType) for value in self.supported_types):
|
||||
raise ValueError("supported_types 必须使用 TaskType")
|
||||
if self.purchase_mode != "dry_run":
|
||||
raise ValueError("当前版本只允许 purchase_mode=dry_run")
|
||||
if self.purchase_mode not in {"dry_run", "live"}:
|
||||
raise ValueError("purchase_mode 只允许 dry_run 或 live")
|
||||
if not self.schema_versions or any(
|
||||
version <= 0 for version in self.schema_versions
|
||||
):
|
||||
@@ -75,6 +75,7 @@ class AdminTask:
|
||||
payload: Mapping[str, Any] = field(default_factory=dict)
|
||||
created_at: str = ""
|
||||
updated_at: str = ""
|
||||
execution_mode: str = "dry_run"
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if not self.task_id.strip():
|
||||
@@ -83,6 +84,13 @@ class AdminTask:
|
||||
raise ValueError("task_type 必须使用 TaskType")
|
||||
if self.version <= 0:
|
||||
raise ValueError("version 必须大于 0")
|
||||
if self.execution_mode not in {"dry_run", "live"}:
|
||||
raise ValueError("execution_mode 只允许 dry_run 或 live")
|
||||
if (
|
||||
self.task_type is not TaskType.PURCHASE
|
||||
and self.execution_mode != "dry_run"
|
||||
):
|
||||
raise ValueError("只有采购任务允许 execution_mode=live")
|
||||
if not isinstance(self.payload, Mapping):
|
||||
raise ValueError("payload 必须是对象")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user