69 lines
1.9 KiB
Go
69 lines
1.9 KiB
Go
package router
|
|
|
|
import (
|
|
"server/internal/handler"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
func SetupSysUserRoutes(r chi.Router, h *handler.SysUserHandler) {
|
|
r.Get("/user", h.ListPage)
|
|
r.Get("/user/info", h.GetUserInfo)
|
|
r.Get("/user/{id}/roles", h.GetRoles)
|
|
r.Post("/user", h.Create)
|
|
r.Patch("/user/{id}", h.Update)
|
|
r.Put("/user/{id}/roles", h.SetRoles)
|
|
r.Patch("/user/{id}/password", h.UpdatePassword)
|
|
r.Delete("/user/{id}", h.Delete)
|
|
}
|
|
|
|
func SetupSysRoleRoutes(r chi.Router, h *handler.SysRoleHandler) {
|
|
r.Get("/role", h.ListPage)
|
|
r.Get("/role/{id}/menus", h.GetRoleMenus)
|
|
r.Get("/role/{id}/apis", h.GetRoleApis)
|
|
r.Get("/role/all", h.GetRoles)
|
|
r.Post("/role", h.Create)
|
|
r.Patch("/role/{id}", h.Update)
|
|
r.Put("/role/{id}/menus", h.SetRoleMenus)
|
|
r.Put("/role/{id}/apis", h.SetRoleApis)
|
|
r.Delete("/role/{id}", h.Delete)
|
|
}
|
|
|
|
func SetupSysMenuRoutes(r chi.Router, h *handler.SysMenuHandler) {
|
|
r.Get("/menu", h.ListPage)
|
|
r.Get("/menu/all", h.GetMenus)
|
|
r.Post("/menu", h.Create)
|
|
r.Patch("/menu/{id}", h.Update)
|
|
r.Delete("/menu/{id}", h.Delete)
|
|
}
|
|
|
|
func SetupSysApiRoutes(r chi.Router, h *handler.SysApiHandler) {
|
|
r.Get("/api", h.ListPage)
|
|
r.Get("/api/all", h.GetAllSysApis)
|
|
r.Get("/api/group-names", h.GetApiGroupNames)
|
|
r.Post("/api", h.Create)
|
|
r.Patch("/api/{id}", h.Update)
|
|
r.Delete("/api/{id}", h.Delete)
|
|
}
|
|
|
|
func SetupSysFileRoutes(r chi.Router, h *handler.SysFileHandler) {
|
|
r.Get("/file", h.ListPage)
|
|
r.Post("/file", h.Upload)
|
|
}
|
|
|
|
func SetupSysPostRoutes(r chi.Router, h *handler.SysPostHandler) {
|
|
r.Get("/post", h.ListPage)
|
|
r.Get("/post/{id}", h.GetPostById)
|
|
r.Post("/post", h.Create)
|
|
r.Patch("/post/{id}", h.Update)
|
|
r.Delete("/post/{id}", h.Delete)
|
|
}
|
|
|
|
func SetupCategoryRoutes(r chi.Router, h *handler.CategoryHandler) {
|
|
r.Get("/category", h.ListPage)
|
|
r.Get("/category/all", h.ListAll)
|
|
r.Post("/category", h.Create)
|
|
r.Patch("/category/{id}", h.Update)
|
|
r.Delete("/category/{id}", h.Delete)
|
|
}
|