Files
blog-server/internal/router/system.go
2026-07-29 22:10:36 +08:00

85 lines
2.3 KiB
Go

package router
import (
"server/internal/handler"
"github.com/go-chi/chi/v5"
)
// SetupSysUserRoutes 8
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)
}
// SetupSysRoleRoutes 9
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)
}
// SetupSysMenuRoutes 5
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)
}
// SetupSysApiRoutes 6
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)
}
// SetupSysFileRoutes 2
func SetupSysFileRoutes(r chi.Router, h *handler.SysFileHandler) {
r.Get("/file", h.ListPage)
r.Post("/file", h.Upload)
}
// SetupSysPostRoutes 5
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)
}
// SetupCategoryRoutes 5
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)
}
// SetupTagRoutes 5
func SetupTagRoutes(r chi.Router, h *handler.TagHandler) {
r.Get("/tag", h.ListPage)
r.Get("/tag/all", h.ListAll)
r.Post("/tag", h.Create)
r.Patch("/tag/{id}", h.Update)
r.Delete("/tag/{id}", h.Delete)
}