代码拉取完成,页面将自动刷新
package logic
import (
"context"
"gitee.com/unitedrhino/core/service/syssvr/internal/repo/relationDB"
"gitee.com/unitedrhino/share/def"
"github.com/samber/lo"
"github.com/zeromicro/go-zero/core/logx"
)
func findMissingParentIds(menuInfos []*relationDB.SysModuleMenu) map[int64]bool {
missingParentIds := make(map[int64]bool)
ids := make(map[int64]bool)
for _, menu := range menuInfos {
ids[menu.ID] = true
}
for _, menu := range menuInfos {
if !ids[menu.ParentID] && menu.ParentID != def.RootNode {
missingParentIds[menu.ParentID] = true
}
}
return missingParentIds
}
func CheckMissingParentIdMenuIndex(ctx context.Context, menuInfos []*relationDB.SysModuleMenu) []*relationDB.SysModuleMenu {
var MenuInfos []*relationDB.SysModuleMenu
missingParentIds := findMissingParentIds(menuInfos)
if len(missingParentIds) > 0 {
menuIDs := lo.Keys(missingParentIds)
menuInfo, err := relationDB.NewMenuInfoRepo(ctx).FindByFilter(ctx, relationDB.MenuInfoFilter{MenuIDs: menuIDs}, nil)
if err != nil {
logx.WithContext(ctx).Errorf("MenuIndex find menu_info err,menuIds:%d,err:%v", menuIDs, err)
return MenuInfos
}
MenuInfos = append(MenuInfos, menuInfo...)
}
return MenuInfos
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。