feat(menu): 添加菜单查询中是否包含按钮类型的参数控制
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ public class SystemMenuController {
|
|||||||
@PostMapping(value = "/listMenuByPid")
|
@PostMapping(value = "/listMenuByPid")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
public ResponseEntity<List<SystemMenuTb>> listMenuByPid(@RequestParam Long pid) {
|
||||||
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid);
|
List<SystemMenuTb> systemMenuTbs = systemMenuService.listMenuByPid(pid, false);
|
||||||
return ResponseEntity.ok(systemMenuTbs);
|
return ResponseEntity.ok(systemMenuTbs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -243,11 +243,15 @@ public class SystemMenuService {
|
|||||||
* @param pid /
|
* @param pid /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public List<SystemMenuTb> listMenuByPid(Long pid) {
|
public List<SystemMenuTb> listMenuByPid(Long pid, boolean includeButton) {
|
||||||
List<SystemMenuTb> menus;
|
List<SystemMenuTb> menus;
|
||||||
if (pid != null && !pid.equals(0L)) {
|
if (pid != null && !pid.equals(0L)) {
|
||||||
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SystemMenuTb> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(SystemMenuTb::getPid, pid);
|
wrapper.eq(SystemMenuTb::getPid, pid);
|
||||||
|
if (!includeButton) {
|
||||||
|
// 是否剔除按钮
|
||||||
|
wrapper.ne(SystemMenuTb::getType, 2);
|
||||||
|
}
|
||||||
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
wrapper.orderByAsc(SystemMenuTb::getMenuSort);
|
||||||
return systemMenuMapper.selectList(wrapper);
|
return systemMenuMapper.selectList(wrapper);
|
||||||
} else {
|
} else {
|
||||||
@@ -268,7 +272,7 @@ public class SystemMenuService {
|
|||||||
menus.addAll(this.listRootMenu());
|
menus.addAll(this.listRootMenu());
|
||||||
return menus;
|
return menus;
|
||||||
}
|
}
|
||||||
menus.addAll(this.listMenuByPid(menu.getPid()));
|
menus.addAll(this.listMenuByPid(menu.getPid(), true));
|
||||||
return querySuperiorMenuByArgs(this.getMenuById(menu.getPid()), menus);
|
return querySuperiorMenuByArgs(this.getMenuById(menu.getPid()), menus);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +393,7 @@ public class SystemMenuService {
|
|||||||
List<SystemMenuTb> newMenuList = new ArrayList<>(menus);
|
List<SystemMenuTb> newMenuList = new ArrayList<>(menus);
|
||||||
return this.buildMenuTree(newMenuList);
|
return this.buildMenuTree(newMenuList);
|
||||||
} else {
|
} else {
|
||||||
List<SystemMenuTb> records = this.listMenuByPid(null);
|
List<SystemMenuTb> records = this.listMenuByPid(null, true);
|
||||||
return KitBeanUtil.copyToList(records, SystemMenuVo.class);
|
return KitBeanUtil.copyToList(records, SystemMenuVo.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -577,7 +581,7 @@ public class SystemMenuService {
|
|||||||
private Set<SystemMenuTb> queryChildMenuByArgs(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
private Set<SystemMenuTb> queryChildMenuByArgs(List<SystemMenuTb> menuList, Set<SystemMenuTb> menuSet) {
|
||||||
for (SystemMenuTb menu : menuList) {
|
for (SystemMenuTb menu : menuList) {
|
||||||
menuSet.add(menu);
|
menuSet.add(menu);
|
||||||
List<SystemMenuTb> menus = this.listMenuByPid(menu.getId());
|
List<SystemMenuTb> menus = this.listMenuByPid(menu.getId(), true);
|
||||||
if (CollUtil.isNotEmpty(menus)) {
|
if (CollUtil.isNotEmpty(menus)) {
|
||||||
queryChildMenuByArgs(menus, menuSet);
|
queryChildMenuByArgs(menus, menuSet);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user