from fastapi import APIRouter
from app.api.v1.endpoints import (
    auth,
    project,
    simulation,
    scada,
    extension,
    snapshots,
    users,
    schemes,
    misc,
    risk,
    cache,
    leakage,
    burst_detection,
    burst_location,
    user_management,  # 新增：用户管理
    audit,  # 新增：审计日志
    meta,
)
from app.api.v1.endpoints.network import (
    general,
    junctions,
    reservoirs,
    tanks,
    pipes,
    pumps,
    valves,
    tags,
    demands,
    geometry,
    regions,
)
from app.api.v1.endpoints.components import (
    curves,
    patterns,
    controls,
    options,
    quality,
    visuals,
)

from app.api.v1.endpoints import project_data
from app.api.v1.endpoints.timeseries import (
    realtime as ts_realtime,
    scheme as ts_scheme,
    scada as ts_scada,
    composite as ts_composite,
)

api_router = APIRouter()

# Core Services
api_router.include_router(auth.router, prefix="/auth", tags=["Auth"])
api_router.include_router(user_management.router, prefix="/users", tags=["User Management"])  # 新增
api_router.include_router(audit.router, prefix="/audit", tags=["Audit Logs"])  # 新增
api_router.include_router(meta.router, tags=["Metadata"])
api_router.include_router(project.router, tags=["Project"])

# Network Elements (Node/Link Types)
api_router.include_router(general.router, tags=["Network General"])
api_router.include_router(junctions.router, tags=["Junctions"])
api_router.include_router(reservoirs.router, tags=["Reservoirs"])
api_router.include_router(tanks.router, tags=["Tanks"])
api_router.include_router(pipes.router, tags=["Pipes"])
api_router.include_router(pumps.router, tags=["Pumps"])
api_router.include_router(valves.router, tags=["Valves"])

# Network Features
api_router.include_router(tags.router, tags=["Tags"])
api_router.include_router(demands.router, tags=["Demands"])
api_router.include_router(geometry.router, tags=["Geometry & Coordinates"])
api_router.include_router(regions.router, tags=["Regions & DMAs"])

# Components & Controls
api_router.include_router(curves.router, tags=["Curves"])
api_router.include_router(patterns.router, tags=["Patterns"])
api_router.include_router(controls.router, tags=["Controls & Rules"])
api_router.include_router(options.router, tags=["Options"])
api_router.include_router(quality.router, tags=["Quality"])
api_router.include_router(visuals.router, tags=["Visuals"])

# Simulation & Data
api_router.include_router(simulation.router, tags=["Simulation Control"])
api_router.include_router(scada.router, tags=["SCADA"])
api_router.include_router(snapshots.router, tags=["Snapshots"])
api_router.include_router(users.router, tags=["Users"])
api_router.include_router(schemes.router, tags=["Schemes"])
api_router.include_router(misc.router, tags=["Misc"])
api_router.include_router(risk.router, tags=["Risk"])
api_router.include_router(cache.router, tags=["Cache"])
api_router.include_router(leakage.router, prefix="/leakage", tags=["Leakage"])
api_router.include_router(
    burst_detection.router, prefix="/burst-detection", tags=["Burst Detection"]
)
api_router.include_router(
    burst_location.router, prefix="/burst-location", tags=["Burst Location"]
)

# TimescaleDB Data Access
api_router.include_router(ts_realtime.router, tags=["TimescaleDB - Realtime"])
api_router.include_router(ts_scheme.router, tags=["TimescaleDB - Scheme"])
api_router.include_router(ts_scada.router, tags=["TimescaleDB - SCADA"])
api_router.include_router(ts_composite.router, tags=["TimescaleDB - Composite"])

# Project Data (PostgreSQL)
api_router.include_router(project_data.router, tags=["Project Data"])

# Extension
api_router.include_router(extension.router, tags=["Extension"])
