1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package route
- import (
- "net/http"
- "github.com/gin-gonic/gin"
- "cp-organization-management-gateway/controller/v1"
- _ "cp-organization-management-gateway/docs"
- "cp-organization-management-gateway/route/middleware"
- )
- func SetupRoute(engine *gin.Engine) {
- // 404页面
- engine.NoRoute(func(c *gin.Context) {
- c.String(http.StatusNotFound, "Not Found")
- })
- // 服务健康检查
- engine.GET("/ping", func(c *gin.Context) {
- // TODO 心跳检查
- c.String(http.StatusOK, "pong")
- })
- //engine.Use(middleware.Session("smart-site-supplier"))
- // version 1
- apiv1 := engine.Group("/api/v1")
- {
- c := v1.NewController()
- engine.POST("/api/v1/user/login", c.Login)
- apiv1.PUT("/token_refresh", c.TokenRefresh)
- apiv1.Use(middleware.Jwt())
-
- system := apiv1.Group("/system")
- {
- userManagement := system.Group("/user")
- {
- userManagement.PUT("", c.UserUpdate)
- userManagement.POST("", c.UserCreate)
- userManagement.DELETE("/:id", c.UserDel)
- userManagement.GET("/list", c.UserList)
- userManagement.GET("/info/:id", c.UserInfo)
- }
- rbac := system.Group("/rbac")
- {
- node := rbac.Group("/node")
- {
- node.GET("/list", c.RbacNodeList)
- }
- group := rbac.Group("/group")
- {
- group.DELETE("/:id", c.RbacGroupDel)
- group.POST("", c.RbacGroupAdd)
- group.GET("/list", c.RbacGroupList)
- group.PUT("", c.RbacGroupUpdate)
- }
- }
- }
- zone := apiv1.Group("/zone")
- {
- zone.POST("", c.ZoneAdd)
- zone.PUT("", c.ZoneUpdate)
- zone.DELETE(":zone_code", c.ZoneDel)
- zone.GET("/list", c.ZoneList)
- }
- }
- }
|