Files
my-v0-server/app/api/materials.py
T
2026-09-30 09:00:44 -07:00

20 lines
639 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.schemas.component_resource import ComponentCatalog
router = APIRouter(prefix="/materials", tags=["Material"])
@router.get("")
async def list_materials() -> ApiResponse[ComponentCatalog]:
# 直接返回启动时载入的内存缓存,不查库
catalog = get_catalog_cache()
if catalog is None:
raise BizException(503, "物料目录尚未加载")
return success_response(catalog)