主要变更: - 新增B端认证系统(后台+H5):登录、登出、Token刷新、密码修改 - 完善商户管理和商户账号管理功能 - 补全单元测试(ShopService: 72.5%, ShopAccountService: 79.8%) - 新增集成测试(商户管理+商户账号管理) - 归档OpenSpec提案(add-shop-account-management, implement-b-end-auth-system) - 完善文档(使用指南、API文档、认证架构说明) 测试统计: - 13个测试套件,37个测试用例,100%通过率 - 平均覆盖率76.2%,达标 OpenSpec验证:通过(strict模式)
65 lines
1.9 KiB
Go
65 lines
1.9 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{"权限"},
|
|
Input: new(model.CreatePermissionRequest),
|
|
Output: new(model.PermissionResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(permissions, doc, groupPath, "GET", "", h.List, RouteSpec{
|
|
Summary: "权限列表",
|
|
Tags: []string{"权限"},
|
|
Input: new(model.PermissionListRequest),
|
|
Output: new(model.PermissionPageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(permissions, doc, groupPath, "GET", "/tree", h.GetTree, RouteSpec{
|
|
Summary: "获取权限树",
|
|
Tags: []string{"权限"},
|
|
Input: nil, // 无参数或 Query 参数
|
|
Output: new([]*model.PermissionTreeNode),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(permissions, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
|
Summary: "获取权限详情",
|
|
Tags: []string{"权限"},
|
|
Input: new(model.IDReq),
|
|
Output: new(model.PermissionResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(permissions, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
|
Summary: "更新权限",
|
|
Tags: []string{"权限"},
|
|
Input: new(model.UpdatePermissionParams),
|
|
Output: new(model.PermissionResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(permissions, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
|
Summary: "删除权限",
|
|
Tags: []string{"权限"},
|
|
Input: new(model.IDReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
}
|