"""
API v1 主路由
"""
from fastapi import APIRouter

from app.api.v1 import (
    auth,
    tenants,
    employees,
    departments,
    department_members,
    roles,
    # identities,  # Removed: EmployeeIdentity and BusinessUnit models have been deleted
    network_drives,
    audit_logs,
    email_accounts,
    permissions,
    lifecycle,
    personal_service_settings,
    emp_onboarding,
    system_functions,
)
from app.api.v1.endpoints import installation, installation_phases

api_router = APIRouter()

# 認證
api_router.include_router(
    auth.router,
    prefix="/auth",
    tags=["Authentication"]
)

# 租戶管理 (多租戶核心)
api_router.include_router(
    tenants.router,
    prefix="/tenants",
    tags=["Tenants"]
)

# 員工管理
api_router.include_router(
    employees.router,
    prefix="/employees",
    tags=["Employees"]
)

# 部門管理 (統一樹狀結構，取代原 business-units)
api_router.include_router(
    departments.router,
    prefix="/departments",
    tags=["Departments"]
)

# 部門成員管理 (員工多部門歸屬)
api_router.include_router(
    department_members.router,
    prefix="/department-members",
    tags=["Department Members"]
)

# 角色管理 (RBAC)
api_router.include_router(
    roles.router,
    prefix="/roles",
    tags=["Roles & RBAC"]
)

# 身份管理 (已廢棄 API，底層 model 已刪除)
# api_router.include_router(
#     identities.router,
#     prefix="/identities",
#     tags=["Employee Identities (Deprecated)"]
# )

# 網路硬碟管理
api_router.include_router(
    network_drives.router,
    prefix="/network-drives",
    tags=["Network Drives"]
)

# 審計日誌
api_router.include_router(
    audit_logs.router,
    prefix="/audit-logs",
    tags=["Audit Logs"]
)

# 郵件帳號管理
api_router.include_router(
    email_accounts.router,
    prefix="/email-accounts",
    tags=["Email Accounts"]
)

# 系統權限管理
api_router.include_router(
    permissions.router,
    prefix="/permissions",
    tags=["Permissions"]
)

# 員工生命週期管理
api_router.include_router(
    lifecycle.router,
    prefix="",
    tags=["Employee Lifecycle"]
)

# 個人化服務設定管理
api_router.include_router(
    personal_service_settings.router,
    prefix="/personal-services",
    tags=["Personal Service Settings"]
)

# 員工到職/離職流程 (v3.1 多租戶架構)
api_router.include_router(
    emp_onboarding.router,
    prefix="/emp-lifecycle",
    tags=["Employee Onboarding (v3.1)"]
)

# 系統初始化與健康檢查
api_router.include_router(
    installation.router,
    prefix="/installation",
    tags=["Installation & Health Check"]
)

# 系統階段轉換（Initialization/Operational/Transition）
api_router.include_router(
    installation_phases.router,
    prefix="/installation",
    tags=["System Phase Management"]
)

# 系統功能管理
api_router.include_router(
    system_functions.router,
    prefix="/system-functions",
    tags=["System Functions"]
)
