router.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. //Router.StaticFS(global.Config.Local.StorePath, http.Dir(global.Config.Local.StorePath))
  14. //docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix
  15. //Router.GET(global.Config.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  16. PublicGroup := Router.Group(global.Config.System.RouterPrefix)
  17. {
  18. PublicGroup.GET("/health", func(c *gin.Context) {
  19. c.JSON(http.StatusOK, "ok")
  20. })
  21. }
  22. {
  23. systemRouter.InitBaseRouter(PublicGroup)
  24. //systemRouter.InitMenuRouter(PublicGroup)
  25. }
  26. PrivateGroup := Router.Group(global.Config.System.RouterPrefix)
  27. PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
  28. //系统层
  29. {
  30. systemRouter.InitApiRouter(PrivateGroup, PublicGroup)
  31. systemRouter.InitJwtRouter(PrivateGroup)
  32. systemRouter.InitUserRouter(PrivateGroup, PublicGroup)
  33. systemRouter.InitMenuRouter(PrivateGroup)
  34. //systemRouter.InitSystemRouter(PrivateGroup)
  35. systemRouter.InitCasbinRouter(PrivateGroup)
  36. //systemRouter.InitAutoCodeRouter(PrivateGroup)
  37. systemRouter.InitAuthorityRouter(PrivateGroup)
  38. systemRouter.InitSysDictionaryRouter(PrivateGroup)
  39. //systemRouter.InitAutoCodeHistoryRouter(PrivateGroup)
  40. //systemRouter.InitSysOperationRecordRouter(PrivateGroup)
  41. systemRouter.InitSysDictionaryDetailRouter(PrivateGroup)
  42. //systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup)
  43. //systemRouter.InitChatGptRouter(PrivateGroup)
  44. }
  45. logrus.Info("router register success")
  46. return Router
  47. }