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.

41 lines
1.7 KiB

  1. package initialize
  2. import (
  3. _ "gin-vue-admin/docs"
  4. "gin-vue-admin/global"
  5. "gin-vue-admin/middleware"
  6. "gin-vue-admin/router"
  7. "github.com/gin-gonic/gin"
  8. "github.com/swaggo/gin-swagger"
  9. "github.com/swaggo/gin-swagger/swaggerFiles"
  10. )
  11. //初始化总路由
  12. func Routers() *gin.Engine {
  13. var Router = gin.Default()
  14. //Router.Use(middleware.LoadTls()) // 打开就能玩https了
  15. global.GVA_LOG.Debug("use middleware logger")
  16. // 跨域
  17. Router.Use(middleware.Cors())
  18. global.GVA_LOG.Debug("use middleware cors")
  19. Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  20. global.GVA_LOG.Debug("register swagger handler")
  21. // 方便统一添加路由组前缀 多服务器上线使用
  22. ApiGroup := Router.Group("")
  23. router.InitUserRouter(ApiGroup) // 注册用户路由
  24. router.InitBaseRouter(ApiGroup) // 注册基础功能路由 不做鉴权
  25. router.InitMenuRouter(ApiGroup) // 注册menu路由
  26. router.InitAuthorityRouter(ApiGroup) // 注册角色路由
  27. router.InitApiRouter(ApiGroup) // 注册功能api路由
  28. router.InitFileUploadAndDownloadRouter(ApiGroup) // 文件上传下载功能路由
  29. router.InitWorkflowRouter(ApiGroup) // 工作流相关路由
  30. router.InitCasbinRouter(ApiGroup) // 权限相关路由
  31. router.InitJwtRouter(ApiGroup) // jwt相关路由
  32. router.InitSystemRouter(ApiGroup) // system相关路由
  33. router.InitCustomerRouter(ApiGroup) // 客户路由
  34. router.InitAutoCodeRouter(ApiGroup) // 创建自动化代码
  35. global.GVA_LOG.Info("router register success")
  36. return Router
  37. }