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.

49 lines
2.2 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. "net/http"
  11. )
  12. // 初始化总路由
  13. func Routers() *gin.Engine {
  14. var Router = gin.Default()
  15. // 为用户头像和文件提供静态地址
  16. Router.StaticFS(global.GVA_CONFIG.LocalUpload.FilePath, http.Dir(global.GVA_CONFIG.LocalUpload.FilePath))
  17. // Router.Use(middleware.LoadTls()) // 打开就能玩https了
  18. global.GVA_LOG.Info("use middleware logger")
  19. // 跨域
  20. Router.Use(middleware.Cors())
  21. global.GVA_LOG.Info("use middleware cors")
  22. Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  23. global.GVA_LOG.Info("register swagger handler")
  24. // 方便统一添加路由组前缀 多服务器上线使用
  25. ApiGroup := Router.Group("")
  26. router.InitUserRouter(ApiGroup) // 注册用户路由
  27. router.InitBaseRouter(ApiGroup) // 注册基础功能路由 不做鉴权
  28. router.InitMenuRouter(ApiGroup) // 注册menu路由
  29. router.InitAuthorityRouter(ApiGroup) // 注册角色路由
  30. router.InitApiRouter(ApiGroup) // 注册功能api路由
  31. router.InitFileUploadAndDownloadRouter(ApiGroup) // 文件上传下载功能路由
  32. router.InitSimpleUploaderRouter(ApiGroup) // 断点续传(插件版)
  33. router.InitWorkflowRouter(ApiGroup) // 工作流相关路由
  34. router.InitCasbinRouter(ApiGroup) // 权限相关路由
  35. router.InitJwtRouter(ApiGroup) // jwt相关路由
  36. router.InitSystemRouter(ApiGroup) // system相关路由
  37. router.InitCustomerRouter(ApiGroup) // 客户路由
  38. router.InitAutoCodeRouter(ApiGroup) // 创建自动化代码
  39. router.InitSysDictionaryDetailRouter(ApiGroup) // 字典详情管理
  40. router.InitSysDictionaryRouter(ApiGroup) // 字典管理
  41. router.InitSysOperationRecordRouter(ApiGroup) // 操作记录
  42. router.InitEmailRouter(ApiGroup) // 邮件相关路由
  43. global.GVA_LOG.Info("router register success")
  44. return Router
  45. }