@Data public class SysUserFavoriteMenu { /** * 账号ID */ private String userId; /** * 菜单ID */ private String menuId; /** * 父菜单ID */ private String parentId; /** * 经销商编码 */ private String did; }
public ListgetFavoriteMenu(String userId,String did){ List sysMenus = new ArrayList<>(); //获取常用菜单叶子节点 List sysUserFavoriteMenuMappers = sysUserFavoriteMenuMapper.getSysUserFavoriteMenu(userId,did); for(SysUserFavoriteMenu sysUserFavoriteMenu : sysUserFavoriteMenuMappers){ //获取叶子节点对应的父节点 SysMenu sysMenu = sysMenuMapper.selectByPrimaryKey(sysUserFavoriteMenu.getParentId()); //把父节点加入sysMenus中 并把这个叶子节点放在这个父节点下 SysMenu child = sysMenuMapper.selectByPrimaryKey(sysUserFavoriteMenu.getMenuId()); child.setIsFavorite("1"); if(sysMenus == null || sysMenus.isEmpty()){ sysMenu.getChildrens().add(child); sysMenus.add(sysMenu); }else{ int flag = 0; for(int a=0;a