Browse Source

动态menu和角色关联以及基础menu构建

main
pixelqm 5 years ago
parent
commit
c6490afe52
  1. 17
      QMPlusServer/model/dbModel/baseMenu.go
  2. 17
      QMPlusServer/model/dbModel/menu_authority.go

17
QMPlusServer/model/dbModel/baseMenu.go

@ -53,3 +53,20 @@ func (b *BaseMenu) GetInfoList(info modelInterface.PageInfo) (err error, list in
return err, menuList, total
}
}
//获取基础路由树
func (m *BaseMenu) GetBaseMenuTree() (err error, menus []BaseMenu) {
err = qmsql.DEFAULTDB.Where(" parent_id = ?", 0).Find(&menus).Error
for i := 0; i < len(menus); i++ {
err = getBaseChildrenList(&menus[i])
}
return err, menus
}
func getBaseChildrenList(menu *BaseMenu) (err error) {
err = qmsql.DEFAULTDB.Where("parent_id = ?", menu.ID).Find(&menu.Children).Error
for i := 0; i < len(menu.Children); i++ {
err = getBaseChildrenList(&menu.Children[i])
}
return err
}

17
QMPlusServer/model/dbModel/menu_authority.go

@ -56,20 +56,3 @@ func getChildrenList(menu *Menu) (err error) {
}
return err
}
//获取基础路由树
func (m *BaseMenu) GetBaseMenuTree() (err error, menus []BaseMenu) {
err = qmsql.DEFAULTDB.Where(" parent_id = ?", 0).Find(&menus).Error
for i := 0; i < len(menus); i++ {
err = getBaseChildrenList(&menus[i])
}
return err, menus
}
func getBaseChildrenList(menu *BaseMenu) (err error) {
err = qmsql.DEFAULTDB.Where("parent_id = ?", menu.ID).Find(&menu.Children).Error
for i := 0; i < len(menu.Children); i++ {
err = getBaseChildrenList(&menu.Children[i])
}
return err
}
Loading…
Cancel
Save