59 lines
1.8 KiB
Go
59 lines
1.8 KiB
Go
package routes
|
|
|
|
import (
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
"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 *admin.PermissionHandler, doc *openapi.Generator, basePath string) {
|
|
permissions := api.Group("/permissions")
|
|
groupPath := basePath + "/permissions"
|
|
|
|
// 权限 CRUD
|
|
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,
|
|
})
|
|
}
|