mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 18:20:50 +00:00
feat✨ admin角色编辑权限改为默认
This commit is contained in:
@@ -46,17 +46,22 @@ func GetMenu(c *gin.Context) {
|
||||
app.OK(c, result, "")
|
||||
}
|
||||
|
||||
// GetMenuTreeRoleselect 角色修改中的菜单列表
|
||||
func GetMenuTreeRoleselect(c *gin.Context) {
|
||||
var Menu models.Menu
|
||||
var SysRole models.SysRole
|
||||
|
||||
id, err := tools.StringToInt(c.Param("roleId"))
|
||||
SysRole.RoleId = id
|
||||
result, err := Menu.SetMenuLable()
|
||||
tools.HasError(err, "抱歉未找到相关信息", -1)
|
||||
var result *[]models.MenuLable
|
||||
menuIds := make([]int, 0)
|
||||
if id != 0 {
|
||||
menuIds, err = SysRole.GetRoleMeunId()
|
||||
if tools.GetRoleName(c) != "admin" {
|
||||
result, err = Menu.SetMenuLable()
|
||||
tools.HasError(err, "抱歉未找到相关信息", -1)
|
||||
if id != 0 {
|
||||
menuIds, err = SysRole.GetRoleMeunId()
|
||||
tools.HasError(err, "抱歉未找到相关信息", -1)
|
||||
}
|
||||
}
|
||||
app.Custum(c, gin.H{
|
||||
"code": 200,
|
||||
|
||||
@@ -146,10 +146,10 @@ func DiguiMenu(menulist *[]Menu, menu Menu) Menu {
|
||||
return menu
|
||||
}
|
||||
|
||||
func (e *Menu) SetMenuLable() (m []MenuLable, err error) {
|
||||
func (e *Menu) SetMenuLable() (m *[]MenuLable, err error) {
|
||||
menulist, err := e.Get()
|
||||
|
||||
m = make([]MenuLable, 0)
|
||||
ml := make([]MenuLable, 0)
|
||||
for i := 0; i < len(menulist); i++ {
|
||||
if menulist[i].ParentId != 0 {
|
||||
continue
|
||||
@@ -159,9 +159,9 @@ func (e *Menu) SetMenuLable() (m []MenuLable, err error) {
|
||||
e.Label = menulist[i].Title
|
||||
menusInfo := DiguiMenuLable(&menulist, e)
|
||||
|
||||
m = append(m, menusInfo)
|
||||
ml = append(ml, menusInfo)
|
||||
}
|
||||
return
|
||||
return &ml, err
|
||||
}
|
||||
|
||||
func DiguiMenuLable(menulist *[]Menu, menu MenuLable) MenuLable {
|
||||
|
||||
@@ -22,9 +22,9 @@ type SysRole struct {
|
||||
DataScope string `json:"dataScope" gorm:"size:128;"`
|
||||
BaseModel
|
||||
|
||||
Params string `json:"params" gorm:"-"`
|
||||
MenuIds []int `json:"menuIds" gorm:"-"`
|
||||
DeptIds []int `json:"deptIds" gorm:"-"`
|
||||
Params string `json:"params" gorm:"-"`
|
||||
MenuIds []int `json:"menuIds" gorm:"-"`
|
||||
DeptIds []int `json:"deptIds" gorm:"-"`
|
||||
}
|
||||
|
||||
func (SysRole) TableName() string {
|
||||
|
||||
Reference in New Issue
Block a user