少提交的东西
This commit is contained in:
@@ -3,18 +3,56 @@ package routes
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
// registerPermissionRoutes 注册权限相关路由
|
||||
func registerPermissionRoutes(api fiber.Router, h *handler.PermissionHandler) {
|
||||
func registerPermissionRoutes(api fiber.Router, h *admin.PermissionHandler, doc *openapi.Generator, basePath string) {
|
||||
permissions := api.Group("/permissions")
|
||||
groupPath := basePath + "/permissions"
|
||||
|
||||
// 权限 CRUD
|
||||
permissions.Post("", h.Create) // POST /api/v1/permissions
|
||||
permissions.Get("", h.List) // GET /api/v1/permissions
|
||||
permissions.Get("/tree", h.GetTree) // GET /api/v1/permissions/tree (注意:放在 :id 之前避免路由冲突)
|
||||
permissions.Get("/:id", h.Get) // GET /api/v1/permissions/:id
|
||||
permissions.Put("/:id", h.Update) // PUT /api/v1/permissions/:id
|
||||
permissions.Delete("/:id", h.Delete) // DELETE /api/v1/permissions/:id
|
||||
Register(permissions, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
||||
Summary: "创建权限",
|
||||
Tags: []string{"Permission"},
|
||||
Input: new(model.CreatePermissionRequest),
|
||||
Output: new(model.PermissionResponse),
|
||||
})
|
||||
|
||||
Register(permissions, doc, groupPath, "GET", "", h.List, RouteSpec{
|
||||
Summary: "权限列表",
|
||||
Tags: []string{"Permission"},
|
||||
Input: new(model.PermissionListRequest),
|
||||
Output: new(model.PermissionPageResult),
|
||||
})
|
||||
|
||||
Register(permissions, doc, groupPath, "GET", "/tree", h.GetTree, RouteSpec{
|
||||
Summary: "获取权限树",
|
||||
Tags: []string{"Permission"},
|
||||
Input: nil, // 无参数或 Query 参数
|
||||
Output: new([]*model.PermissionTreeNode),
|
||||
})
|
||||
|
||||
Register(permissions, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
||||
Summary: "获取权限详情",
|
||||
Tags: []string{"Permission"},
|
||||
Input: new(model.IDReq),
|
||||
Output: new(model.PermissionResponse),
|
||||
})
|
||||
|
||||
Register(permissions, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
||||
Summary: "更新权限",
|
||||
Tags: []string{"Permission"},
|
||||
Input: new(model.UpdatePermissionParams),
|
||||
Output: new(model.PermissionResponse),
|
||||
})
|
||||
|
||||
Register(permissions, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
||||
Summary: "删除权限",
|
||||
Tags: []string{"Permission"},
|
||||
Input: new(model.IDReq),
|
||||
Output: nil,
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user