主要变更: - 新增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模式)
90 lines
2.5 KiB
Go
90 lines
2.5 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"
|
|
)
|
|
|
|
// registerRoleRoutes 注册角色相关路由
|
|
func registerRoleRoutes(api fiber.Router, h *admin.RoleHandler, doc *openapi.Generator, basePath string) {
|
|
roles := api.Group("/roles")
|
|
groupPath := basePath + "/roles"
|
|
|
|
// 角色 CRUD
|
|
Register(roles, doc, groupPath, "POST", "", h.Create, RouteSpec{
|
|
Summary: "创建角色",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.CreateRoleRequest),
|
|
Output: new(model.RoleResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "GET", "", h.List, RouteSpec{
|
|
Summary: "角色列表",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.RoleListRequest),
|
|
Output: new(model.RolePageResult),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "GET", "/:id", h.Get, RouteSpec{
|
|
Summary: "获取角色详情",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.IDReq),
|
|
Output: new(model.RoleResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "PUT", "/:id", h.Update, RouteSpec{
|
|
Summary: "更新角色",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.UpdateRoleParams),
|
|
Output: new(model.RoleResponse),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "PUT", "/:id/status", h.UpdateStatus, RouteSpec{
|
|
Summary: "更新角色状态",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.UpdateRoleStatusParams),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "DELETE", "/:id", h.Delete, RouteSpec{
|
|
Summary: "删除角色",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.IDReq),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
// 角色-权限关联
|
|
Register(roles, doc, groupPath, "POST", "/:id/permissions", h.AssignPermissions, RouteSpec{
|
|
Summary: "分配权限",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.AssignPermissionsParams),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "GET", "/:id/permissions", h.GetPermissions, RouteSpec{
|
|
Summary: "获取角色权限",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.IDReq),
|
|
Output: new([]model.Permission),
|
|
Auth: true,
|
|
})
|
|
|
|
Register(roles, doc, groupPath, "DELETE", "/:role_id/permissions/:perm_id", h.RemovePermission, RouteSpec{
|
|
Summary: "移除权限",
|
|
Tags: []string{"角色"},
|
|
Input: new(model.RemovePermissionParams),
|
|
Output: nil,
|
|
Auth: true,
|
|
})
|
|
}
|