feat:物料存入数据库
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
"""前端物料目录接口"""
|
||||
|
||||
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)
|
||||
Reference in New Issue
Block a user