feat:架构重构
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
|
||||
from pydantic import JsonValue
|
||||
|
||||
from app.schemas.component_resource import ComponentCatalog, ComponentDefinition
|
||||
from app.schemas.component_resource import (
|
||||
ComponentCatalog,
|
||||
ComponentDefinition,
|
||||
ComponentSummary,
|
||||
)
|
||||
from app.schemas.material_field import (
|
||||
MISSING,
|
||||
PANEL_CONTROLS,
|
||||
@@ -82,6 +86,24 @@ def material_payload(component: ComponentDefinition) -> dict:
|
||||
return component.model_dump(mode="json", by_alias=True, exclude={"field_groups"})
|
||||
|
||||
|
||||
def list_components(catalog: ComponentCatalog) -> dict:
|
||||
"""组件目录摘要:选类型用,默认配置和字段定义另行查询"""
|
||||
return {
|
||||
"catalog_version": catalog.version,
|
||||
"components": [
|
||||
ComponentSummary(
|
||||
key=item.key,
|
||||
type=item.type,
|
||||
name=item.name,
|
||||
description=item.description,
|
||||
default_width=item.schema_.layout.width,
|
||||
default_height=item.schema_.layout.height,
|
||||
).model_dump(mode="json")
|
||||
for item in catalog.components
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def get_materials(catalog: ComponentCatalog, component_types: list[str]) -> dict:
|
||||
"""指定类型的物料默认配置,同一类型的多个预设全部返回"""
|
||||
known = {item.type for item in catalog.components}
|
||||
|
||||
Reference in New Issue
Block a user