2026-04-23 23:37:39 +08:00
|
|
|
from fastapi import APIRouter
|
2026-04-23 23:57:34 +08:00
|
|
|
import importlib
|
2026-04-23 23:37:39 +08:00
|
|
|
|
2026-05-29 18:10:08 +08:00
|
|
|
from shared.utils.logger import get_logger
|
2026-04-23 23:57:34 +08:00
|
|
|
|
|
|
|
|
logger = get_logger(__name__)
|
2026-04-23 23:37:39 +08:00
|
|
|
|
|
|
|
|
router = APIRouter()
|
2026-04-23 23:57:34 +08:00
|
|
|
|
|
|
|
|
def _safe_include(module_path: str, label: str):
|
|
|
|
|
try:
|
|
|
|
|
module = importlib.import_module(module_path)
|
|
|
|
|
router_obj = getattr(module, "router", None)
|
|
|
|
|
if router_obj is None:
|
|
|
|
|
raise ValueError("未找到 router 对象")
|
|
|
|
|
router.include_router(router_obj)
|
|
|
|
|
logger.info(f"{label} 路由加载成功")
|
|
|
|
|
except Exception as exc:
|
|
|
|
|
logger.warning(f"{label} 路由加载失败,已跳过: {exc}")
|
|
|
|
|
|
|
|
|
|
|
2026-05-29 18:10:08 +08:00
|
|
|
_safe_include("moldinsight.api.health_router", "健康检查")
|
|
|
|
|
_safe_include("moldinsight.api.upload_router", "上传")
|
|
|
|
|
_safe_include("moldinsight.api.task_router", "任务")
|
|
|
|
|
_safe_include("moldinsight.api.history_router", "历史")
|
|
|
|
|
_safe_include("moldinsight.api.debug_router", "调试")
|
|
|
|
|
_safe_include("moldinsight.api.cam_router", "CAM")
|
|
|
|
|
_safe_include("moldinsight.api.advanced_router", "高级")
|
2026-07-13 17:44:50 +08:00
|
|
|
_safe_include("moldinsight.api.aluminum_price_routes", "铝价")
|