新增接口 根据目录ID查询所有的父级目录ID

This commit is contained in:
WangHao
2020-08-30 17:59:09 +08:00
parent 102b94e4d1
commit f38e3e9bc7
3 changed files with 45 additions and 7 deletions

View File

@ -12,6 +12,15 @@ import com.ruoyi.bookmark.domain.SqMenu;
public interface ISqMenuService
{
/**
* 查询 目录菜单的 所有父级ID
*
* @param menuId
* @return 结果
*/
public Long[] selectBymenuidParentid(Long menuId);
/**
* 批量减少目录下书签数量
*

View File

@ -1,5 +1,6 @@
package com.ruoyi.bookmark.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -20,6 +21,31 @@ public class SqMenuServiceImpl implements ISqMenuService
@Autowired
private SqMenuMapper sqMenuMapper;
/**
* 查询 目录菜单的 所有父级ID
*
* @param menuId
* @return 结果
*/
@Override
public Long[] selectBymenuidParentid(Long menuId){
List<Long> menuIds=new ArrayList<>();
while (!menuId.toString().equals("0")) {
SqMenu sqMenu = sqMenuMapper.selectSqMenuById(menuId);
if (!sqMenu.getParentId().toString().equals("0")) {
menuIds.add(sqMenu.getParentId());
}
menuId = sqMenu.getParentId();
}
Long[] menuIdArry = menuIds.toArray(new Long[menuIds.size()]);
return menuIdArry;
}
/**
* @auther: Wang
* @date: 2020/08/16 20:04