后端: - 种子数据:超级管理员(admin/admin123)、super_admin 角色、22 条菜单(含按钮权限码)、角色绑定 - admin_menu 扩展 icon/component/hidden 字段(003_schema_ext.sql),手动补齐 entity/do/table - auth 扩展:/auth/info、/auth/codes(仅登录),路由拆分公开/Profile/受保护三组 - 菜单路由:/menu/routes 返回 vben backend 动态路由树(按角色过滤、排序) - RBAC 管理:/admins、/roles、/menus CRUD(含角色绑定、重置密码、菜单授权) - 日志监控:/log/files、/log/tail(尾部读取+关键词过滤+路径穿越防护) - 安全加固:接口鉴权改为「方法+路径→权限码」自动映射,杜绝任意权限码越权 - 修复:gf v2.10.2 不自动替换→cmd 注入;MySQL driver 需显式引入 contrib - 全链路冒烟测试通过(含越权拒绝 30003)
63 lines
1.9 KiB
Go
63 lines
1.9 KiB
Go
package v1
|
|
|
|
import "github.com/gogf/gf/v2/frame/g"
|
|
|
|
// RoleItem is one row of the role list.
|
|
type RoleItem struct {
|
|
Id uint64 `json:"id"`
|
|
Code string `json:"code"`
|
|
Name string `json:"name"`
|
|
Status int `json:"status"`
|
|
MenuIds []uint64 `json:"menuIds"` // bound menu ids (for editing)
|
|
CreatedAt string `json:"createdAt"`
|
|
}
|
|
|
|
// RoleListReq pages the roles.
|
|
type RoleListReq struct {
|
|
g.Meta `path:"/roles" method:"get" tags:"Admin/Role" summary:"Role list"`
|
|
Page int `json:"page" d:"1" v:"min:1"`
|
|
Size int `json:"size" d:"10" v:"min:1|max:100"`
|
|
Keyword string `json:"keyword"` // matches code or name
|
|
}
|
|
|
|
// RoleListRes is the response of RoleListReq.
|
|
type RoleListRes struct {
|
|
List []*RoleItem `json:"list"`
|
|
Total int `json:"total"`
|
|
}
|
|
|
|
// RoleCreateReq creates a role and binds menu ids.
|
|
type RoleCreateReq struct {
|
|
g.Meta `path:"/roles" method:"post" tags:"Admin/Role" summary:"Create role"`
|
|
Code string `json:"code" v:"required"`
|
|
Name string `json:"name" v:"required"`
|
|
Status int `json:"status"`
|
|
MenuIds []uint64 `json:"menuIds"`
|
|
}
|
|
|
|
// RoleCreateRes is the response of RoleCreateReq.
|
|
type RoleCreateRes struct {
|
|
Id uint64 `json:"id"`
|
|
}
|
|
|
|
// RoleUpdateReq updates a role and rebinds menu ids.
|
|
type RoleUpdateReq struct {
|
|
g.Meta `path:"/roles/{id}" method:"put" tags:"Admin/Role" summary:"Update role"`
|
|
Id uint64 `json:"id" in:"path" v:"required"`
|
|
Name string `json:"name" v:"required"`
|
|
Status int `json:"status"`
|
|
MenuIds []uint64 `json:"menuIds"`
|
|
}
|
|
|
|
// RoleUpdateRes is the response of RoleUpdateReq.
|
|
type RoleUpdateRes struct{}
|
|
|
|
// RoleDeleteReq deletes a role (soft delete).
|
|
type RoleDeleteReq struct {
|
|
g.Meta `path:"/roles/{id}" method:"delete" tags:"Admin/Role" summary:"Delete role"`
|
|
Id uint64 `json:"id" in:"path" v:"required"`
|
|
}
|
|
|
|
// RoleDeleteRes is the response of RoleDeleteReq.
|
|
type RoleDeleteRes struct{}
|