router.go 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package initialize
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "lcfns/global"
  6. "lcfns/middleware"
  7. "lcfns/router"
  8. "net/http"
  9. )
  10. func Routers() *gin.Engine {
  11. Router := gin.Default()
  12. systemRouter := router.RouterGroupApp.System
  13. isApiRouter := router.RouterGroupApp.IsApi
  14. appRouterGroup := router.RouterGroupApp.AppGroup
  15. ipcast := router.RouterGroupApp.Ipcast
  16. //Router.StaticFS(global.Config.Local.StorePath, http.Dir(global.Config.Local.StorePath))
  17. //docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix
  18. //Router.GET(global.Config.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  19. PublicGroup := Router.Group(global.Config.System.RouterPrefix)
  20. {
  21. PublicGroup.GET("/health", func(c *gin.Context) {
  22. c.JSON(http.StatusOK, "ok")
  23. })
  24. }
  25. {
  26. systemRouter.InitBaseRouter(PublicGroup)
  27. //systemRouter.InitMenuRouter(PublicGroup)
  28. }
  29. PrivateGroup := Router.Group(global.Config.System.RouterPrefix)
  30. PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
  31. //系统层
  32. {
  33. systemRouter.InitApiRouter(PrivateGroup, PublicGroup)
  34. systemRouter.InitJwtRouter(PrivateGroup)
  35. systemRouter.InitUserRouter(PrivateGroup, PublicGroup)
  36. systemRouter.InitMenuRouter(PrivateGroup)
  37. //systemRouter.InitSystemRouter(PrivateGroup)
  38. systemRouter.InitCasbinRouter(PrivateGroup)
  39. //systemRouter.InitAutoCodeRouter(PrivateGroup)
  40. systemRouter.InitAuthorityRouter(PrivateGroup)
  41. systemRouter.InitSysDictionaryRouter(PrivateGroup)
  42. //systemRouter.InitAutoCodeHistoryRouter(PrivateGroup)
  43. //systemRouter.InitSysOperationRecordRouter(PrivateGroup)
  44. systemRouter.InitSysDictionaryDetailRouter(PrivateGroup)
  45. //systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup)
  46. //systemRouter.InitChatGptRouter(PrivateGroup)
  47. }
  48. //isapi
  49. {
  50. isApiRouter.InitInfoRouter(PrivateGroup)
  51. }
  52. //ipcast
  53. {
  54. ipcast.InitInfoRouter(PrivateGroup, PublicGroup)
  55. }
  56. //应用层
  57. {
  58. appRouterGroup.GatewayRouter.InitInfoRouter(PrivateGroup)
  59. appRouterGroup.CameraRouter.InitInfoRouter(PrivateGroup)
  60. appRouterGroup.EventRouter.InitInfoRouter(PrivateGroup)
  61. appRouterGroup.PictureRouter.InitInfoRouter(PrivateGroup)
  62. }
  63. logrus.Info("router register success")
  64. return Router
  65. }