feat(role): 新增平台角色管理功能增强
- 权限表增加 available_for_role_types 字段,支持标记权限可用角色类型 - 权限列表和权限树接口支持按 available_for_role_type 过滤 - 新增角色状态切换接口 PUT /api/admin/roles/:id/status - 角色分配权限时验证权限的可用角色类型 - 完善数据库迁移脚本和单元测试 - 补充数据库迁移相关开发规范文档
This commit is contained in:
@@ -9,14 +9,15 @@ type Permission struct {
|
||||
gorm.Model
|
||||
BaseModel `gorm:"embedded"`
|
||||
|
||||
PermName string `gorm:"column:perm_name;not null;size:50;comment:权限名称" json:"perm_name"`
|
||||
PermCode string `gorm:"column:perm_code;uniqueIndex:idx_permission_code,where:deleted_at IS NULL;not null;size:100;comment:权限编码" json:"perm_code"`
|
||||
PermType int `gorm:"column:perm_type;not null;index;comment:权限类型 1=菜单 2=按钮" json:"perm_type"`
|
||||
Platform string `gorm:"column:platform;type:varchar(20);default:'all';comment:适用端口 all=全部 web=Web后台 h5=H5端" json:"platform"`
|
||||
URL string `gorm:"column:url;size:255;comment:URL路径" json:"url,omitempty"`
|
||||
ParentID *uint `gorm:"column:parent_id;index;comment:上级权限ID" json:"parent_id,omitempty"`
|
||||
Sort int `gorm:"column:sort;not null;default:0;comment:排序" json:"sort"`
|
||||
Status int `gorm:"column:status;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"`
|
||||
PermName string `gorm:"column:perm_name;not null;size:50;comment:权限名称" json:"perm_name"`
|
||||
PermCode string `gorm:"column:perm_code;uniqueIndex:idx_permission_code,where:deleted_at IS NULL;not null;size:100;comment:权限编码" json:"perm_code"`
|
||||
PermType int `gorm:"column:perm_type;not null;index;comment:权限类型 1=菜单 2=按钮" json:"perm_type"`
|
||||
Platform string `gorm:"column:platform;type:varchar(20);default:'all';comment:适用端口 all=全部 web=Web后台 h5=H5端" json:"platform"`
|
||||
AvailableForRoleTypes string `gorm:"column:available_for_role_types;type:varchar(20);default:'1,2';not null;comment:可用角色类型 1=平台 2=客户" json:"available_for_role_types"`
|
||||
URL string `gorm:"column:url;size:255;comment:URL路径" json:"url,omitempty"`
|
||||
ParentID *uint `gorm:"column:parent_id;index;comment:上级权限ID" json:"parent_id,omitempty"`
|
||||
Sort int `gorm:"column:sort;not null;default:0;comment:排序" json:"sort"`
|
||||
Status int `gorm:"column:status;not null;default:1;comment:状态 0=禁用 1=启用" json:"status"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
|
||||
Reference in New Issue
Block a user