2026-03-12 09:28:19 +00:00
|
|
|
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")
|
2026-03-13 08:35:54 +00:00
|
|
|
api.POST("/login", handler.AuthLogin)
|
2026-03-12 09:28:19 +00:00
|
|
|
|
|
|
|
|
protected := router.Group("/api")
|
|
|
|
|
protected.Use(auth(), authorize())
|
2026-03-13 08:35:54 +00:00
|
|
|
protected.POST("/logout", handler.AuthLogout)
|
|
|
|
|
protected.GET("/me", handler.AuthMe)
|
|
|
|
|
|
|
|
|
|
protected.GET("/orgs", handler.OrgList)
|
|
|
|
|
protected.POST("/orgs", handler.OrgCreate)
|
2026-03-18 09:18:06 +00:00
|
|
|
protected.GET("/orgs/:id", handler.OrgDetail)
|
2026-03-13 08:35:54 +00:00
|
|
|
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)
|
2026-03-18 09:18:06 +00:00
|
|
|
protected.GET("/options", handler.OptionMap)
|
2026-03-19 09:35:11 +00:00
|
|
|
|
|
|
|
|
protected.GET("/users", handler.UserList)
|
|
|
|
|
protected.POST("/users", handler.UserCreate)
|
|
|
|
|
protected.GET("/users/:id", handler.UserGet)
|
|
|
|
|
protected.PUT("/users/:id", handler.UserUpdate)
|
|
|
|
|
protected.DELETE("/users/:id", handler.UserDelete)
|
|
|
|
|
protected.PUT("/users/:id/password", handler.UserPasswordUpdate)
|
2026-03-12 09:28:19 +00:00
|
|
|
}
|