sys_menu.go 383 B

123456789101112131415
  1. package services
  2. import "eta/eta_mini_crm_ht/models"
  3. // GetMenuTreeRecursive 递归菜单树
  4. func GetMenuTreeRecursive(list []*models.SysMenuItem, parentId int) []*models.SysMenuItem {
  5. res := make([]*models.SysMenuItem, 0)
  6. for _, v := range list {
  7. if v.ParentId == parentId {
  8. v.Children = GetMenuTreeRecursive(list, v.SysMenuId)
  9. res = append(res, v)
  10. }
  11. }
  12. return res
  13. }