router.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. product,
  13. proxy,
  14. slot,
  15. sms,
  16. task,
  17. ticket,
  18. user,
  19. vas_task,
  20. webhook,
  21. )
  22. # 公共路由
  23. public_router = APIRouter()
  24. # 受保护路由
  25. protected_router = APIRouter()
  26. # 管理员级别路由
  27. admin_required_router = APIRouter()
  28. # 模块列表
  29. _modules = [
  30. account,
  31. auth,
  32. common,
  33. config,
  34. email,
  35. notification,
  36. order,
  37. payment,
  38. plugin,
  39. product,
  40. proxy,
  41. slot,
  42. sms,
  43. task,
  44. ticket,
  45. user,
  46. vas_task,
  47. webhook,
  48. ]
  49. # 注册所有子模块路由
  50. for _mod in _modules:
  51. if hasattr(_mod, "public_router") and _mod.public_router.routes:
  52. public_router.include_router(_mod.public_router)
  53. if hasattr(_mod, "protected_router") and _mod.protected_router.routes:
  54. protected_router.include_router(_mod.protected_router)
  55. if hasattr(_mod, "admin_required_router") and _mod.admin_required_router.routes:
  56. admin_required_router.include_router(_mod.admin_required_router)