router.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. package initialize
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "github.com/sirupsen/logrus"
  5. "lc-fangdaosha/global"
  6. "lc-fangdaosha/middleware"
  7. "lc-fangdaosha/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. //Router.StaticFS(global.Config.Local.StorePath, http.Dir(global.Config.Local.StorePath))
  16. //docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix
  17. //Router.GET(global.Config.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  18. PublicGroup := Router.Group(global.Config.System.RouterPrefix)
  19. {
  20. PublicGroup.GET("/health", func(c *gin.Context) {
  21. c.JSON(http.StatusOK, "ok")
  22. })
  23. }
  24. {
  25. systemRouter.InitBaseRouter(PublicGroup)
  26. //systemRouter.InitMenuRouter(PublicGroup)
  27. }
  28. PrivateGroup := Router.Group(global.Config.System.RouterPrefix)
  29. PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
  30. //系统层
  31. {
  32. systemRouter.InitApiRouter(PrivateGroup, PublicGroup)
  33. systemRouter.InitJwtRouter(PrivateGroup)
  34. systemRouter.InitUserRouter(PrivateGroup, PublicGroup)
  35. systemRouter.InitMenuRouter(PrivateGroup)
  36. //systemRouter.InitSystemRouter(PrivateGroup)
  37. systemRouter.InitCasbinRouter(PrivateGroup)
  38. //systemRouter.InitAutoCodeRouter(PrivateGroup)
  39. systemRouter.InitAuthorityRouter(PrivateGroup)
  40. systemRouter.InitSysDictionaryRouter(PrivateGroup)
  41. //systemRouter.InitAutoCodeHistoryRouter(PrivateGroup)
  42. //systemRouter.InitSysOperationRecordRouter(PrivateGroup)
  43. systemRouter.InitSysDictionaryDetailRouter(PrivateGroup)
  44. //systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup)
  45. //systemRouter.InitChatGptRouter(PrivateGroup)
  46. }
  47. //isapi
  48. {
  49. isApiRouter.InitInfoRouter(PrivateGroup) //isapi
  50. }
  51. //应用层
  52. {
  53. appRouterGroup.GatewayRouter.InitGatewayRouter(PrivateGroup) //网关
  54. appRouterGroup.CameraRouter.InitCameraRouter(PrivateGroup) //摄像机
  55. appRouterGroup.EventRouter.InitInfoRouter(PrivateGroup) //事件
  56. appRouterGroup.PictureRouter.InitInfoRouter(PrivateGroup) //图片
  57. }
  58. logrus.Info("router register success")
  59. return Router
  60. }