- factor_composite 表(migration c3e9a0d1f4b5,MySQL 已应用;name 唯一) - CompositeDefinition/Component 实体 + CompositeRepository Protocol + SQLAlchemy 实现 - /api/composites:POST(注册表自动填充组件 direction;未注册因子 400)、GET 列表/详情、DELETE - tests/test_composites_api.py(repo CRUD/同名拒绝/删除、API 方向填充/404/400);全量 pytest 通过
20 lines
586 B
Python
20 lines
586 B
Python
"""Composite Factor Repository Protocol(M7.2b)。"""
|
||
|
||
from __future__ import annotations
|
||
|
||
from typing import Protocol
|
||
|
||
from app.domain.entities.composite import CompositeDefinition
|
||
|
||
|
||
class CompositeRepository(Protocol):
|
||
def save(self, definition: CompositeDefinition) -> CompositeDefinition:
|
||
"""新建组合(name 冲突抛 ValueError)。"""
|
||
|
||
def get(self, composite_id: str) -> CompositeDefinition | None: ...
|
||
|
||
def list(self) -> list[CompositeDefinition]: ...
|
||
|
||
def delete(self, composite_id: str) -> bool:
|
||
"""删除;不存在返回 False。"""
|