router.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. from fastapi import APIRouter
  2. from app.api.endpoints import (
  3. account,
  4. agency,
  5. agent,
  6. auth,
  7. common,
  8. config,
  9. cost,
  10. node_configuration,
  11. email,
  12. fault,
  13. notification,
  14. order,
  15. payment,
  16. plugin,
  17. product,
  18. provider,
  19. proxy,
  20. settlement,
  21. slot,
  22. sms,
  23. task,
  24. ticket,
  25. user,
  26. vas_task,
  27. webhook,
  28. )
  29. # 公共路由
  30. public_router = APIRouter()
  31. # 受保护路由
  32. protected_router = APIRouter()
  33. # 管理员级别路由
  34. admin_required_router = APIRouter()
  35. # 模块列表
  36. _modules = [
  37. account,
  38. agency,
  39. agent,
  40. auth,
  41. common,
  42. config,
  43. cost,
  44. node_configuration,
  45. email,
  46. fault,
  47. notification,
  48. order,
  49. payment,
  50. plugin,
  51. product,
  52. provider,
  53. proxy,
  54. settlement,
  55. slot,
  56. sms,
  57. task,
  58. ticket,
  59. user,
  60. vas_task,
  61. webhook,
  62. ]
  63. # 注册所有子模块路由
  64. for _mod in _modules:
  65. if hasattr(_mod, "public_router") and _mod.public_router.routes:
  66. public_router.include_router(_mod.public_router)
  67. if hasattr(_mod, "protected_router") and _mod.protected_router.routes:
  68. protected_router.include_router(_mod.protected_router)
  69. if hasattr(_mod, "admin_required_router") and _mod.admin_required_router.routes:
  70. admin_required_router.include_router(_mod.admin_required_router)