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.

57 lines
2.5 KiB

  1. package initialize
  2. import (
  3. v1 "gin-vue-admin/api/v1"
  4. _ "gin-vue-admin/docs"
  5. "gin-vue-admin/global"
  6. "gin-vue-admin/middleware"
  7. "gin-vue-admin/router"
  8. "net/http"
  9. "github.com/gin-gonic/gin"
  10. "github.com/swaggo/gin-swagger"
  11. "github.com/swaggo/gin-swagger/swaggerFiles"
  12. )
  13. // 初始化总路由
  14. func Routers() *gin.Engine {
  15. var Router = gin.Default()
  16. Router.POST("initdb", v1.InitDB)
  17. Router.StaticFS(global.GVA_CONFIG.Local.Path, http.Dir(global.GVA_CONFIG.Local.Path)) // 为用户头像和文件提供静态地址
  18. // Router.Use(middleware.LoadTls()) // 打开就能玩https了
  19. global.GVA_LOG.Info("use middleware logger")
  20. // 跨域
  21. Router.Use(middleware.Cors())
  22. global.GVA_LOG.Info("use middleware cors")
  23. Router.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
  24. global.GVA_LOG.Info("register swagger handler")
  25. // 方便统一添加路由组前缀 多服务器上线使用
  26. PublicGroup := Router.Group("")
  27. {
  28. router.InitBaseRouter(PublicGroup) // 注册基础功能路由 不做鉴权
  29. }
  30. PrivateGroup := Router.Group("")
  31. PrivateGroup.Use(middleware.JWTAuth()).Use(middleware.CasbinHandler())
  32. {
  33. router.InitApiRouter(PrivateGroup) // 注册功能api路由
  34. router.InitJwtRouter(PrivateGroup) // jwt相关路由
  35. router.InitUserRouter(PrivateGroup) // 注册用户路由
  36. router.InitMenuRouter(PrivateGroup) // 注册menu路由
  37. router.InitEmailRouter(PrivateGroup) // 邮件相关路由
  38. router.InitSystemRouter(PrivateGroup) // system相关路由
  39. router.InitCasbinRouter(PrivateGroup) // 权限相关路由
  40. router.InitCustomerRouter(PrivateGroup) // 客户路由
  41. router.InitAutoCodeRouter(PrivateGroup) // 创建自动化代码
  42. router.InitAuthorityRouter(PrivateGroup) // 注册角色路由
  43. router.InitSimpleUploaderRouter(PrivateGroup) // 断点续传(插件版)
  44. router.InitSysDictionaryRouter(PrivateGroup) // 字典管理
  45. router.InitSysOperationRecordRouter(PrivateGroup) // 操作记录
  46. router.InitSysDictionaryDetailRouter(PrivateGroup) // 字典详情管理
  47. router.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
  48. router.InitWorkflowProcessRouter(PrivateGroup) // 工作流相关接口
  49. router.InitExcelRouter(PrivateGroup) // 表格导入导出
  50. }
  51. global.GVA_LOG.Info("router register success")
  52. return Router
  53. }