菜单相关优化

v1.4.1
hiparker 4 years ago
parent d71f4883a8
commit 40f03ba1d0

@ -61,7 +61,7 @@ public interface MenuApi {
/** /**
* *
* @param parentId ID * @param parentId ID
* @return * @return ResultVo
*/ */
@GetMapping("/findMenuTreePageByLazy") @GetMapping("/findMenuTreePageByLazy")
ResultVo<?> findMenuTreePageByLazy(String parentId); ResultVo<?> findMenuTreePageByLazy(String parentId);
@ -69,11 +69,11 @@ public interface MenuApi {
/** /**
* *
* @param parentId ID * @param parentId ID
* @return * @param id ID
* @return ResultVo
*/ */
@GetMapping("/findMenuTreeByLazy") @GetMapping("/findMenuTreeByLazy")
ResultVo<?> findMenuTreeByLazy(String parentId); ResultVo<?> findMenuTreeByLazy(String parentId, String id);
/** /**
* *

@ -167,13 +167,15 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
/** /**
* *
* @param parentId ID
* @param id ID
* @return ResultVo * @return ResultVo
*/ */
@ApiOperation(value = "获得菜单树 懒加载", notes = "获得菜单树 懒加载") @ApiOperation(value = "获得菜单树 懒加载", notes = "获得菜单树 懒加载")
@RequiresPermissions("system_menu_select") @RequiresPermissions("system_menu_select")
@Override @Override
public ResultVo<?> findMenuTreeByLazy(String parentId) { public ResultVo<?> findMenuTreeByLazy(String parentId, String id) {
List<MenuModel> menuModelList; List<MenuModel> menuModelList;
if(StringUtils.isEmpty(parentId)){ if(StringUtils.isEmpty(parentId)){
menuModelList = Lists.newArrayList(); menuModelList = Lists.newArrayList();
@ -190,9 +192,17 @@ public class MenuRestController extends BaseRestController<SysMenu, MenuModel, I
// 只查菜单 // 只查菜单
QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>(); QueryBuilder<SysMenu> queryBuilder = new GenQueryBuilder<>();
QueryWrapper<SysMenu> queryWrapper = queryBuilder.build(); QueryWrapper<SysMenu> queryWrapper = queryBuilder.build();
queryWrapper.eq(HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId); queryWrapper.eq(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_PARENT_ID), parentId);
queryWrapper.eq("type", "1"); queryWrapper.eq("type", "1");
// 如果传入ID 则不包含自身
if(StringUtils.isNotEmpty(id)){
queryWrapper.notIn(
HumpUtil.humpToUnderline(MyBatisConstants.FIELD_ID), id);
}
// 获得菜单 // 获得菜单
List<SysMenu> menuList = IService.findList(queryWrapper); List<SysMenu> menuList = IService.findList(queryWrapper);
menuModelList = WrapperUtil.transformInstance(menuList, MenuModel.class); menuModelList = WrapperUtil.transformInstance(menuList, MenuModel.class);

Loading…
Cancel
Save