新增接口 根据目录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") @GetMapping("/selectMenuByUserID")
public AjaxResult selecByUserID() public AjaxResult selecByUserID()
{ {
@ -118,6 +119,11 @@ public class SqMenuController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody SqMenu sqMenu) public AjaxResult edit(@RequestBody SqMenu sqMenu)
{ {
//查询书签的所有上级
//查询当前移动目录的 所有下级书签数量(包括下级目录书签)
return toAjax(sqMenuService.updateSqMenu(sqMenu)); return toAjax(sqMenuService.updateSqMenu(sqMenu));
} }
@ -160,16 +166,22 @@ public class SqMenuController extends BaseController
// * 批量更新书签的数量 // * 批量更新书签的数量
// */ // */
// //
@RequestMapping("/bookmarkcount") @RequestMapping("/bookmarkcount/{menuId}")
public void bookmarkcount() public AjaxResult bookmarkcount(@PathVariable Long menuId)
{ {
// Long[] menuIds={1L,2L,3L}; // Long[] menuIds={1L,2L,3L};
//所有的父级目录 //所有的父级目录
Long[] menuIds= sqMenuService.selectBymenuidParentid(4L); // Long[] menuIds= sqMenuService.selectBymenuidParentid(4L);
sqMenuService.updateCountAdd(menuIds,5); // 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("执行完毕"); 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 * 查询 目录菜单的 所有父级ID
* *
* @param menuId 目录ID * @param menuId 目录ID

View File

@ -21,7 +21,32 @@ public class SqMenuServiceImpl implements ISqMenuService
@Autowired @Autowired
private SqMenuMapper sqMenuMapper; 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;
}
/** /**