ferry/router/router.go

75 lines
2.1 KiB
Go
Raw Permalink Normal View History

2020-07-13 20:33:20 +08:00
package router
import (
"ferry/apis/tpl"
2020-07-13 20:33:20 +08:00
"ferry/pkg/jwtauth"
2020-08-13 21:45:10 +08:00
"ferry/router/dashboard"
2020-07-15 01:40:56 +08:00
"ferry/router/process"
systemRouter "ferry/router/system"
2020-07-13 20:33:20 +08:00
"github.com/gin-gonic/gin"
_ "github.com/gin-gonic/gin"
)
2020-08-17 01:24:51 +08:00
func InitSysRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) *gin.RouterGroup {
2020-07-15 01:40:56 +08:00
g := r.Group("")
2020-08-17 01:24:51 +08:00
systemRouter.SysBaseRouter(g)
2020-07-15 01:40:56 +08:00
// 静态文件
sysStaticFileRouter(g, r)
2020-07-15 01:40:56 +08:00
// swagger注意生产环境可以注释掉
2023-11-28 22:18:28 +08:00
//sysSwaggerRouter(g)
2020-07-13 20:33:20 +08:00
2020-07-15 01:40:56 +08:00
// 无需认证
2020-08-17 01:24:51 +08:00
systemRouter.SysNoCheckRoleRouter(g)
2020-07-15 01:40:56 +08:00
// 需要认证
sysCheckRoleRouterInit(g, authMiddleware)
2020-07-13 20:33:20 +08:00
2020-07-15 01:40:56 +08:00
return g
2020-07-13 20:33:20 +08:00
}
func sysStaticFileRouter(r *gin.RouterGroup, g *gin.Engine) {
2021-04-15 18:13:07 +08:00
r.Static("/static", "./static")
g.LoadHTMLGlob("template/web/index.html")
2020-07-15 01:40:56 +08:00
}
2020-07-13 20:33:20 +08:00
2023-11-28 22:18:28 +08:00
//func sysSwaggerRouter(r *gin.RouterGroup) {
// r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//}
2020-07-13 20:33:20 +08:00
2020-07-15 01:40:56 +08:00
func sysCheckRoleRouterInit(r *gin.RouterGroup, authMiddleware *jwtauth.GinJWTMiddleware) {
r.POST("/login", authMiddleware.LoginHandler)
// Refresh time can be longer than token timeout
r.GET("/refresh_token", authMiddleware.RefreshHandler)
v1 := r.Group("/api/v1")
// 兼容前后端不分离的情
r.GET("/", tpl.Tpl)
2020-07-23 00:42:46 +08:00
// 首页
2020-08-13 21:45:10 +08:00
dashboard.RegisterDashboardRouter(v1, authMiddleware)
2020-07-23 00:42:46 +08:00
2020-07-15 01:40:56 +08:00
// 系统管理
systemRouter.RegisterPageRouter(v1, authMiddleware)
systemRouter.RegisterBaseRouter(v1, authMiddleware)
systemRouter.RegisterDeptRouter(v1, authMiddleware)
systemRouter.RegisterSysUserRouter(v1, authMiddleware)
systemRouter.RegisterRoleRouter(v1, authMiddleware)
systemRouter.RegisterUserCenterRouter(v1, authMiddleware)
systemRouter.RegisterPostRouter(v1, authMiddleware)
systemRouter.RegisterMenuRouter(v1, authMiddleware)
systemRouter.RegisterLoginLogRouter(v1, authMiddleware)
2020-08-19 01:09:01 +08:00
systemRouter.RegisterSysSettingRouter(v1, authMiddleware)
2020-07-15 01:40:56 +08:00
// 流程中心
process.RegisterClassifyRouter(v1, authMiddleware)
process.RegisterProcessRouter(v1, authMiddleware)
process.RegisterTaskRouter(v1, authMiddleware)
process.RegisterTplRouter(v1, authMiddleware)
process.RegisterWorkOrderRouter(v1, authMiddleware)
2020-07-13 20:33:20 +08:00
}