heritage-api/gin/router-gin.go

59 lines
2.0 KiB
Go

package gin
import (
"github.com/gin-gonic/gin"
"myschools.me/heritage/heritage-api/handler"
)
// 路由配置
func routerSetup(router *gin.Engine) {
router.Use(gin.Recovery())
api := router.Group("/api")
api.POST("/login", handler.AuthLogin)
protected := router.Group("/api")
protected.Use(auth(), authorize())
protected.POST("/logout", handler.AuthLogout)
protected.GET("/me", handler.AuthMe)
protected.POST("/password", handler.AuthChangePassword)
protected.GET("/orgs", handler.OrgList)
protected.POST("/orgs", handler.OrgCreate)
protected.GET("/orgs/:id", handler.OrgDetail)
protected.PUT("/orgs/:id", handler.OrgUpdate)
protected.DELETE("/orgs/:id", handler.OrgDelete)
protected.GET("/projects", handler.ProjectList)
protected.POST("/projects", handler.ProjectCreate)
protected.GET("/projects/:id", handler.ProjectGet)
protected.PUT("/projects/:id", handler.ProjectUpdate)
protected.DELETE("/projects/:id", handler.ProjectDelete)
protected.GET("/tasks", handler.TaskList)
protected.POST("/tasks", handler.TaskCreate)
protected.GET("/tasks/:id", handler.TaskGet)
protected.PUT("/tasks/:id", handler.TaskUpdate)
protected.DELETE("/tasks/:id", handler.TaskDelete)
protected.GET("/points", handler.PointList)
protected.POST("/points", handler.PointCreate)
protected.GET("/points/:id", handler.PointGet)
protected.PUT("/points/:id", handler.PointUpdate)
protected.DELETE("/points/:id", handler.PointDelete)
protected.GET("/data-records", handler.DataList)
protected.POST("/data-records", handler.DataCreate)
protected.GET("/data-records/:id", handler.DataGet)
protected.PUT("/data-records/:id", handler.DataUpdate)
protected.DELETE("/data-records/:id", handler.DataDelete)
protected.GET("/devices", handler.DeviceList)
protected.POST("/devices", handler.DeviceCreate)
protected.GET("/devices/:id", handler.DeviceGet)
protected.PUT("/devices/:id", handler.DeviceUpdate)
protected.DELETE("/devices/:id", handler.DeviceDelete)
protected.GET("/menus", handler.MenuList)
protected.GET("/options", handler.OptionMap)
}