1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- package initialize
- import (
- "net/http"
- _ "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"
- "github.com/swaggo/gin-swagger"
- "github.com/swaggo/gin-swagger/swaggerFiles"
- )
- // 初始化总路由
- func Routers() *gin.Engine {
- var Router = gin.Default()
- // 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
- // VUE_APP_BASE_API = /
- // VUE_APP_BASE_PATH = http://localhost
- // 然后执行打包命令 npm run build。在打开下面4行注释
- //Router.LoadHTMLGlob("./dist/*.html") // npm打包成dist的路径
- //Router.Static("/favicon.ico", "./dist/favicon.ico")
- //Router.Static("/static", "./dist/static") // dist里面的静态资源
- //Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
- Router.StaticFS(global.GVA_CONFIG.Local.Path, http.Dir(global.GVA_CONFIG.Local.Path)) // 为用户头像和文件提供静态地址
- // Router.Use(middleware.LoadTls()) // 打开就能玩https了
- global.GVA_LOG.Info("use middleware logger")
- // 跨域
- //Router.Use(middleware.Cors()) // 如需跨域可以打开
- global.GVA_LOG.Info("use middleware cors")
- Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
- global.GVA_LOG.Info("register swagger handler")
- // 方便统一添加路由组前缀 多服务器上线使用
- //获取路由组实例
- systemRouter := router.RouterGroupApp.System
- exampleRouter := router.RouterGroupApp.Example
- autocodeRouter := router.RouterGroupApp.Autocode
- PublicGroup := Router.Group("")
- {
- systemRouter.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权
- systemRouter.InitInitRouter(PublicGroup) // 自动初始化相关
- autocodeRouter.InitProblemInfoPRouter(PublicGroup) // 问题详情
- autocodeRouter.InitContentPRouter(PublicGroup) // 内容详情
- }
- PrivateGroup := Router.Group("")
- PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
- {
- systemRouter.InitApiRouter(PrivateGroup) // 注册功能api路由
- systemRouter.InitJwtRouter(PrivateGroup) // jwt相关路由
- systemRouter.InitUserRouter(PrivateGroup) // 注册用户路由
- systemRouter.InitMenuRouter(PrivateGroup) // 注册menu路由
- systemRouter.InitSystemRouter(PrivateGroup) // system相关路由
- systemRouter.InitCasbinRouter(PrivateGroup) // 权限相关路由
- systemRouter.InitAutoCodeRouter(PrivateGroup) // 创建自动化代码
- systemRouter.InitAuthorityRouter(PrivateGroup) // 注册角色路由
- systemRouter.InitSysDictionaryRouter(PrivateGroup) // 字典管理
- systemRouter.InitSysOperationRecordRouter(PrivateGroup) // 操作记录
- systemRouter.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理
- exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
- exampleRouter.InitExcelRouter(PrivateGroup) // 表格导入导出
- exampleRouter.InitCustomerRouter(PrivateGroup) // 客户路由
- // Code generated by github.com/flipped-aurora/gin-vue-admin/server Begin; DO NOT EDIT.
- autocodeRouter.InitSysAutoCodeExampleRouter(PrivateGroup)
- autocodeRouter.InitContentRouter(PrivateGroup)
- autocodeRouter.InitProblemInfoRouter(PrivateGroup)
- autocodeRouter.InitPlaceRouter(PrivateGroup)
- // Code generated by github.com/flipped-aurora/gin-vue-admin/server End; DO NOT EDIT.
- }
- InstallPlugin(PublicGroup, PrivateGroup) // 安装插件
- global.GVA_LOG.Info("router register success")
- return Router
- }
|