1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- package initialize
- import (
- "github.com/flipped-aurora/gin-vue-admin/server/docs"
- "github.com/flipped-aurora/gin-vue-admin/server/global"
- "github.com/flipped-aurora/gin-vue-admin/server/middleware"
- "github.com/flipped-aurora/gin-vue-admin/server/router"
- "github.com/gin-gonic/gin"
- swaggerFiles "github.com/swaggo/files"
- ginSwagger "github.com/swaggo/gin-swagger"
- "net/http"
- "os"
- )
- type justFilesFilesystem struct {
- fs http.FileSystem
- }
- func (fs justFilesFilesystem) Open(name string) (http.File, error) {
- f, err := fs.fs.Open(name)
- if err != nil {
- return nil, err
- }
- stat, err := f.Stat()
- if stat.IsDir() {
- return nil, os.ErrPermission
- }
- return f, nil
- }
- func Routers() *gin.Engine {
- Router := gin.New()
- Router.Use(gin.Recovery())
- if gin.Mode() == gin.DebugMode {
- Router.Use(gin.Logger())
- }
- InstallPlugin(Router)
- systemRouter := router.RouterGroupApp.System
-
-
-
-
-
-
-
- Router.StaticFS(global.GVA_CONFIG.Local.StorePath, justFilesFilesystem{http.Dir(global.GVA_CONFIG.Local.StorePath)})
-
-
-
-
- docs.SwaggerInfo.BasePath = global.GVA_CONFIG.System.RouterPrefix
- Router.GET(global.GVA_CONFIG.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
- global.GVA_LOG.Info("register swagger handler")
-
- PublicGroup := Router.Group(global.GVA_CONFIG.System.RouterPrefix)
- {
-
- PublicGroup.GET("/health", func(c *gin.Context) {
- c.JSON(http.StatusOK, "ok")
- })
- }
- {
- systemRouter.InitBaseRouter(PublicGroup)
- systemRouter.InitInitRouter(PublicGroup)
- }
- PrivateGroup := Router.Group(global.GVA_CONFIG.System.RouterPrefix)
- PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
- {
- systemRouter.InitApiRouter(PrivateGroup, PublicGroup)
- systemRouter.InitJwtRouter(PrivateGroup)
- systemRouter.InitUserRouter(PrivateGroup)
- 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.InitSysExportTemplateRouter(PrivateGroup)
- }
- global.GVA_LOG.Info("router register success")
- return Router
- }
|