#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
路由模块初始化文件
集中管理所有API路由的导入
"""

# 导入所有路由模块
from routes.database import router as db_router
from routes.template_api import router as template_router
from routes.task_api import router as task_router
from routes.common_api import router as common_router
from routes.task_edit_api import router as task_edit_router
from routes.task_record_api import router as task_record_router
from routes.calldevice_api import router as calldevice_router
from routes.modbus_config_api import router as modbus_config_router
from routes.websocket_api import router as websocket_router
from routes.map_data_api import router as map_data_router
from routes.operate_point_api import router as operate_point_router
from routes.external_task_api import router as external_task_router
from routes.script_api import router as script_router
from routes.script_websocket_api import router as script_websocket_router
from routes.lsp_websocket_api import router as lsp_websocket_router
from routes.dynamic_api import router as dynamic_api_router
from routes.map_converter_api import router as map_converter_router

# 路由列表，按照注册顺序排列
routers = [
    common_router,
    db_router,
    template_router,
    task_router,
    task_edit_router,
    task_record_router,
    calldevice_router,
    modbus_config_router,
    websocket_router,
    map_data_router,
    operate_point_router,
    external_task_router,
    script_router,
    script_websocket_router,
    lsp_websocket_router,
    # (script_router, "/api/script"),  # 脚本管理API
    # (script_websocket_router, "/api/script"),  # 脚本WebSocket API
    dynamic_api_router,  # 动态API路由（脚本注册的API）,
    map_converter_router
]

def register_routers(app):
    """
    注册所有路由到FastAPI应用
    
    Args:
        app: FastAPI应用实例
    """
    for router_config in routers:
        if isinstance(router_config, tuple):
            # 带前缀的路由
            router, prefix = router_config
            app.include_router(router, prefix=prefix)
        else:
            # 普通路由
            app.include_router(router_config)

# from fastapi import FastAPI

# # 导入所有路由文件
# from routes import (
#     hello_api,
#     task_edit_api,
#     task_record_api,  # 新增的任务记录API
#     # ... 其他路由模块
# )

# def register_all_routes(app: FastAPI) -> None:
#     """
#     注册所有路由到FastAPI应用
#     """
#     # 注册各模块的路由
#     app.include_router(hello_api.router)
#     app.include_router(task_edit_api.router)
#     app.include_router(task_record_api.router)  # 注册任务记录API路由
#     # ... 注册其他路由 