20 lines
689 B
Python
20 lines
689 B
Python
"""前端物料目录接口"""
|
|
|
|
from fastapi import APIRouter
|
|
|
|
from app.common.response import ApiResponse, success_response
|
|
from app.core.exceptions import BizException
|
|
from app.resources.component import get_catalog_cache
|
|
from app.resources.material_fields import frontend_catalog
|
|
|
|
router = APIRouter(prefix="/materials", tags=["Material"])
|
|
|
|
|
|
@router.get("")
|
|
async def list_materials() -> ApiResponse[dict]:
|
|
# 直接使用启动时载入的内存缓存,不查库;属性面板 setters 由字段定义派生
|
|
catalog = get_catalog_cache()
|
|
if catalog is None:
|
|
raise BizException(503, "物料目录尚未加载")
|
|
return success_response(frontend_catalog(catalog))
|