package initialize import ( "github.com/gin-gonic/gin" "github.com/sirupsen/logrus" "lc-fangdaosha/global" "lc-fangdaosha/middleware" "lc-fangdaosha/router" "net/http" ) func Routers() *gin.Engine { Router := gin.Default() systemRouter := router.RouterGroupApp.System isApiRouter := router.RouterGroupApp.IsApi appRouterGroup := router.RouterGroupApp.AppGroup //Router.StaticFS(global.Config.Local.StorePath, http.Dir(global.Config.Local.StorePath)) //docs.SwaggerInfo.BasePath = global.Config.System.RouterPrefix //Router.GET(global.Config.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) PublicGroup := Router.Group(global.Config.System.RouterPrefix) { PublicGroup.GET("/health", func(c *gin.Context) { c.JSON(http.StatusOK, "ok") }) } { systemRouter.InitBaseRouter(PublicGroup) //systemRouter.InitMenuRouter(PublicGroup) } PrivateGroup := Router.Group(global.Config.System.RouterPrefix) PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler()) //系统层 { systemRouter.InitApiRouter(PrivateGroup, PublicGroup) systemRouter.InitJwtRouter(PrivateGroup) systemRouter.InitUserRouter(PrivateGroup, PublicGroup) systemRouter.InitMenuRouter(PrivateGroup) //systemRouter.InitSystemRouter(PrivateGroup) systemRouter.InitCasbinRouter(PrivateGroup) //systemRouter.InitAutoCodeRouter(PrivateGroup) systemRouter.InitAuthorityRouter(PrivateGroup) systemRouter.InitSysDictionaryRouter(PrivateGroup) //systemRouter.InitAutoCodeHistoryRouter(PrivateGroup) //systemRouter.InitSysOperationRecordRouter(PrivateGroup) systemRouter.InitSysDictionaryDetailRouter(PrivateGroup) //systemRouter.InitAuthorityBtnRouterRouter(PrivateGroup) //systemRouter.InitChatGptRouter(PrivateGroup) } //isapi { isApiRouter.InitInfoRouter(PrivateGroup) //isapi } //应用层 { appRouterGroup.GatewayRouter.InitGatewayRouter(PrivateGroup) //网关 appRouterGroup.CameraRouter.InitCameraRouter(PrivateGroup) //摄像机 appRouterGroup.EventRouter.InitInfoRouter(PrivateGroup) //事件 appRouterGroup.PictureRouter.InitInfoRouter(PrivateGroup) //图片 } logrus.Info("router register success") return Router }