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

This commit is contained in:
WangHao 2020-08-30 19:42:42 +08:00
parent 713d9e0197
commit d62720f5a7
3 changed files with 49 additions and 4 deletions

View File

@ -39,6 +39,7 @@ public class SqMenuController extends BaseController
/**
* 功能描述:查询用户的 所有书签菜单
*/
@GetMapping("/selectMenuByUserID")
public AjaxResult selecByUserID()
{
@ -118,6 +119,11 @@ public class SqMenuController extends BaseController
@PutMapping
public AjaxResult edit(@RequestBody SqMenu sqMenu)
{
//查询书签的所有上级
//查询当前移动目录的 所有下级书签数量(包括下级目录书签)
return toAjax(sqMenuService.updateSqMenu(sqMenu));
}
@ -160,16 +166,22 @@ public class SqMenuController extends BaseController
// * 批量更新书签的数量
// */
//
@RequestMapping("/bookmarkcount")
public void bookmarkcount()
@RequestMapping("/bookmarkcount/{menuId}")
public AjaxResult bookmarkcount(@PathVariable Long menuId)
{
// Long[] menuIds={1L,2L,3L};
//所有的父级目录
Long[] menuIds= sqMenuService.selectBymenuidParentid(4L);
sqMenuService.updateCountAdd(menuIds,5);
// Long[] menuIds= sqMenuService.selectBymenuidParentid(4L);
// sqMenuService.updateCountAdd(menuIds,5);
Long[] menuIds= sqMenuService.selectBymenuidsubordinateid(menuId);
for (int i=0;i<menuIds.length;i++){
System.out.println("id:"+menuIds[i].toString());
}
logger.info("执行完毕");
return AjaxResult.success(menuIds);
}

View File

@ -14,6 +14,14 @@ public interface ISqMenuService
/**
* 查询 目录菜单的 所有下级ID
*
* @param menuId 目录ID
* @return 结果
*/
public Long[] selectBymenuidsubordinateid(Long menuId);
/**
* 查询 目录菜单的 所有父级ID
*
* @param menuId 目录ID

View File

@ -21,7 +21,32 @@ public class SqMenuServiceImpl implements ISqMenuService
@Autowired
private SqMenuMapper sqMenuMapper;
/**
* 查询 目录菜单的 所有父级ID
*
* @param menuId
* @return 所有的下级MenuID
*/
@Override
public Long[] selectBymenuidsubordinateid(Long menuId){
List<Long> menuIds=new ArrayList<>();
Boolean flag=true;
while (flag) {
SqMenu sqMenu=new SqMenu();
sqMenu.setParentId(menuId);
SqMenu Menu = sqMenuMapper.selectOne(sqMenu);
if (Menu!=null) {
menuIds.add(Menu.getMenuId());
menuId = Menu.getMenuId();
}else {
flag=false;
}
}
Long[] menuIdArry = menuIds.toArray(new Long[menuIds.size()]);
return menuIdArry;
}
/**