You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
2.1 KiB

package initialize
import (
_ "gin-vue-admin/docs"
"gin-vue-admin/global"
"gin-vue-admin/middleware"
"gin-vue-admin/router"
"github.com/gin-gonic/gin"
"github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"net/http"
)
// 初始化总路由
func Routers() *gin.Engine {
var Router = gin.Default()
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")
// 方便统一添加路由组前缀 多服务器上线使用
ApiGroup := Router.Group("")
router.InitUserRouter(ApiGroup) // 注册用户路由
router.InitBaseRouter(ApiGroup) // 注册基础功能路由 不做鉴权
router.InitMenuRouter(ApiGroup) // 注册menu路由
router.InitAuthorityRouter(ApiGroup) // 注册角色路由
router.InitApiRouter(ApiGroup) // 注册功能api路由
router.InitFileUploadAndDownloadRouter(ApiGroup) // 文件上传下载功能路由
router.InitSimpleUploaderRouter(ApiGroup) // 断点续传(插件版)
router.InitCasbinRouter(ApiGroup) // 权限相关路由
router.InitJwtRouter(ApiGroup) // jwt相关路由
router.InitSystemRouter(ApiGroup) // system相关路由
router.InitCustomerRouter(ApiGroup) // 客户路由
router.InitAutoCodeRouter(ApiGroup) // 创建自动化代码
router.InitSysDictionaryDetailRouter(ApiGroup) // 字典详情管理
router.InitSysDictionaryRouter(ApiGroup) // 字典管理
router.InitSysOperationRecordRouter(ApiGroup) // 操作记录
router.InitEmailRouter(ApiGroup) // 邮件相关路由
global.GVA_LOG.Info("router register success")
return Router
}