|
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author huangyuan
|
|
@@ -54,15 +55,17 @@ public class RoleMenuService extends ServiceImpl<RoleMenuMapper, RoleMenu> imple
|
|
|
@Override
|
|
|
public List<Menu> getMenuTree(Long roleId) {
|
|
|
List<RoleMenu> roleMenuList = this.list(new QueryWrapper<RoleMenu>()
|
|
|
- .eq("role_id", roleId)
|
|
|
+ .eq("role_id", roleId)
|
|
|
);
|
|
|
- List<Long> menuIds = ProjectUtils.getAttrList(roleMenuList, "menuId", null);
|
|
|
- if(menuIds != null && menuIds.size() > 0){
|
|
|
- //获取所有菜单
|
|
|
- List<Menu> menuList = (List<Menu>) menuService.listByIds(menuIds);
|
|
|
- return menuService.getMenuTree(menuList);
|
|
|
+ if (roleMenuList != null && roleMenuList.size() > 0) {
|
|
|
+ List<Long> menuIds = roleMenuList.stream().map(RoleMenu::getMenuId).collect(Collectors.toList());
|
|
|
+ if (menuIds.size() > 0) {
|
|
|
+ //获取所有菜单
|
|
|
+ List<Menu> menuList = (List<Menu>) menuService.listByIds(menuIds);
|
|
|
+ //将菜单转化为树
|
|
|
+ return menuService.getMenuTree(menuList);
|
|
|
+ }
|
|
|
}
|
|
|
- //将菜单转化为树
|
|
|
return null;
|
|
|
}
|
|
|
}
|