Search in sources :

Example 1 with SysPermissionTree

use of org.jeecg.modules.system.model.SysPermissionTree in project jeecg-boot by jeecgboot.

the class SysPermissionController method getSystemSubmenu.

/**
 * 查询子菜单
 * @param parentId
 * @return
 */
@RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId) {
    Result<List<SysPermissionTree>> result = new Result<>();
    try {
        LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
        query.eq(SysPermission::getParentId, parentId);
        query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
        query.orderByAsc(SysPermission::getSortNo);
        List<SysPermission> list = sysPermissionService.list(query);
        List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
        for (SysPermission sysPermission : list) {
            SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
            sysPermissionTreeList.add(sysPermissionTree);
        }
        result.setResult(sysPermissionTreeList);
        result.setSuccess(true);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return result;
}
Also used : SysPermissionTree(org.jeecg.modules.system.model.SysPermissionTree) Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 2 with SysPermissionTree

use of org.jeecg.modules.system.model.SysPermissionTree in project jeecg-boot by jeecgboot.

the class SysPermissionController method getTreeList.

private void getTreeList(List<SysPermissionTree> treeList, List<SysPermission> metaList, SysPermissionTree temp) {
    for (SysPermission permission : metaList) {
        String tempPid = permission.getParentId();
        SysPermissionTree tree = new SysPermissionTree(permission);
        if (temp == null && oConvertUtils.isEmpty(tempPid)) {
            treeList.add(tree);
            if (!tree.getIsLeaf()) {
                getTreeList(treeList, metaList, tree);
            }
        } else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) {
            temp.getChildren().add(tree);
            if (!tree.getIsLeaf()) {
                getTreeList(treeList, metaList, tree);
            }
        }
    }
}
Also used : SysPermissionTree(org.jeecg.modules.system.model.SysPermissionTree)

Example 3 with SysPermissionTree

use of org.jeecg.modules.system.model.SysPermissionTree in project jeecg-boot by jeecgboot.

the class SysPermissionController method getSystemSubmenuBatch.

/*update_end author:wuxianquan date:20190908 for:先查询一级菜单,当用户点击展开菜单时加载子菜单 */
// update_begin author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
/**
 * 查询子菜单
 *
 * @param parentIds 父ID(多个采用半角逗号分割)
 * @return 返回 key-value 的 Map
 */
@GetMapping("/getSystemSubmenuBatch")
public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
    try {
        LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
        List<String> parentIdList = Arrays.asList(parentIds.split(","));
        query.in(SysPermission::getParentId, parentIdList);
        query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
        query.orderByAsc(SysPermission::getSortNo);
        List<SysPermission> list = sysPermissionService.list(query);
        Map<String, List<SysPermissionTree>> listMap = new HashMap<>();
        for (SysPermission item : list) {
            String pid = item.getParentId();
            if (parentIdList.contains(pid)) {
                List<SysPermissionTree> mapList = listMap.get(pid);
                if (mapList == null) {
                    mapList = new ArrayList<>();
                }
                mapList.add(new SysPermissionTree(item));
                listMap.put(pid, mapList);
            }
        }
        return Result.ok(listMap);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        return Result.error("批量查询子菜单失败:" + e.getMessage());
    }
}
Also used : LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) SysPermissionTree(org.jeecg.modules.system.model.SysPermissionTree)

Example 4 with SysPermissionTree

use of org.jeecg.modules.system.model.SysPermissionTree in project kms by mahonelau.

the class SysPermissionController method getSystemSubmenu.

/**
 * 查询子菜单
 * @param parentId
 * @return
 */
@RequestMapping(value = "/getSystemSubmenu", method = RequestMethod.GET)
public Result<List<SysPermissionTree>> getSystemSubmenu(@RequestParam("parentId") String parentId) {
    Result<List<SysPermissionTree>> result = new Result<>();
    try {
        LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
        query.eq(SysPermission::getParentId, parentId);
        query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
        query.orderByAsc(SysPermission::getSortNo);
        List<SysPermission> list = sysPermissionService.list(query);
        List<SysPermissionTree> sysPermissionTreeList = new ArrayList<SysPermissionTree>();
        for (SysPermission sysPermission : list) {
            SysPermissionTree sysPermissionTree = new SysPermissionTree(sysPermission);
            sysPermissionTreeList.add(sysPermissionTree);
        }
        result.setResult(sysPermissionTreeList);
        result.setSuccess(true);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return result;
}
Also used : SysPermission(org.jeecg.modules.system.entity.SysPermission) SysPermissionTree(org.jeecg.modules.system.model.SysPermissionTree) Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)

Example 5 with SysPermissionTree

use of org.jeecg.modules.system.model.SysPermissionTree in project kms by mahonelau.

the class SysPermissionController method getTreeList.

private void getTreeList(List<SysPermissionTree> treeList, List<SysPermission> metaList, SysPermissionTree temp) {
    for (SysPermission permission : metaList) {
        String tempPid = permission.getParentId();
        SysPermissionTree tree = new SysPermissionTree(permission);
        if (temp == null && oConvertUtils.isEmpty(tempPid)) {
            treeList.add(tree);
            if (!tree.getIsLeaf()) {
                getTreeList(treeList, metaList, tree);
            }
        } else if (temp != null && tempPid != null && tempPid.equals(temp.getId())) {
            temp.getChildren().add(tree);
            if (!tree.getIsLeaf()) {
                getTreeList(treeList, metaList, tree);
            }
        }
    }
}
Also used : SysPermission(org.jeecg.modules.system.entity.SysPermission) SysPermissionTree(org.jeecg.modules.system.model.SysPermissionTree)

Aggregations

SysPermissionTree (org.jeecg.modules.system.model.SysPermissionTree)12 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)9 SysPermission (org.jeecg.modules.system.entity.SysPermission)8 Result (org.jeecg.common.api.vo.Result)6