router.py 1.2 KB

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