forked from lxh/go-wxhelper
🎨 优化菜单数据返回结果,只返回顶级菜单的rank值
This commit is contained in:
parent
1d1ca21815
commit
63c8c3a292
@ -15,7 +15,7 @@ type Item struct {
|
||||
type ItemMeta struct {
|
||||
Title string `json:"title"` // 标题
|
||||
Icon string `json:"icon"` // 图标
|
||||
Rank int `json:"rank"` // 排序
|
||||
Rank int `json:"rank,omitempty"` // 排序
|
||||
Roles []string `json:"roles"` // 当前菜单所属的角色代码
|
||||
Auths []string `json:"auths"` // 当前菜单包含的按钮,如果传入了用户Id,返回的将会是权限内所有的按钮
|
||||
}
|
||||
|
@ -30,7 +30,10 @@ func toTree(records []menuRecordItem, pid string) (tree []menu.Item) {
|
||||
var meta menu.ItemMeta
|
||||
meta.Title = record.Title
|
||||
meta.Icon = record.Icon
|
||||
// rank只有顶级菜单才返回rank值
|
||||
if record.ParentId == nil || *record.ParentId == "" {
|
||||
meta.Rank = record.Sort
|
||||
}
|
||||
if record.RoleCode != "" {
|
||||
meta.Roles = strings.Split(record.RoleCode, ",")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user