Search in sources :

Example 1 with TreeModel

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

the class SysDepartPermissionController method queryTreeListForDeptRole.

/**
 * 用户角色授权功能,查询菜单权限树
 * @param request
 * @return
 */
@RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeListForDeptRole(@RequestParam(name = "departId", required = true) String departId, HttpServletRequest request) {
    Result<Map<String, Object>> result = new Result<>();
    // 全部权限ids
    List<String> ids = new ArrayList<>();
    try {
        LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
        query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
        query.orderByAsc(SysPermission::getSortNo);
        query.inSql(SysPermission::getId, "select permission_id  from sys_depart_permission where depart_id='" + departId + "'");
        List<SysPermission> list = sysPermissionService.list(query);
        for (SysPermission sysPer : list) {
            ids.add(sysPer.getId());
        }
        List<TreeModel> treeList = new ArrayList<>();
        getTreeModelList(treeList, list, null);
        Map<String, Object> resMap = new HashMap<String, Object>();
        // 全部树节点数据
        resMap.put("treeList", treeList);
        // 全部树ids
        resMap.put("ids", ids);
        result.setResult(resMap);
        result.setSuccess(true);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return result;
}
Also used : Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) TreeModel(org.jeecg.modules.system.model.TreeModel) SysPermission(org.jeecg.modules.system.entity.SysPermission) JSONObject(com.alibaba.fastjson.JSONObject)

Example 2 with TreeModel

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

the class SysDepartPermissionController method getTreeModelList.

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

Example 3 with TreeModel

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

the class SysPermissionController method getTreeModelList.

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

Example 4 with TreeModel

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

the class SysPermissionController method queryTreeList.

/**
 * 获取全部的权限树
 *
 * @return
 */
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
public Result<Map<String, Object>> queryTreeList() {
    Result<Map<String, Object>> result = new Result<>();
    // 全部权限ids
    List<String> ids = new ArrayList<>();
    try {
        LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
        query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
        query.orderByAsc(SysPermission::getSortNo);
        List<SysPermission> list = sysPermissionService.list(query);
        for (SysPermission sysPer : list) {
            ids.add(sysPer.getId());
        }
        List<TreeModel> treeList = new ArrayList<>();
        getTreeModelList(treeList, list, null);
        Map<String, Object> resMap = new HashMap<String, Object>();
        // 全部树节点数据
        resMap.put("treeList", treeList);
        // 全部树ids
        resMap.put("ids", ids);
        result.setResult(resMap);
        result.setSuccess(true);
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
    return result;
}
Also used : Result(org.jeecg.common.api.vo.Result) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) TreeModel(org.jeecg.modules.system.model.TreeModel) SysPermission(org.jeecg.modules.system.entity.SysPermission) JSONObject(com.alibaba.fastjson.JSONObject)

Example 5 with TreeModel

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

the class SysPermissionController method getTreeModelList.

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

Aggregations

TreeModel (org.jeecg.modules.system.model.TreeModel)17 SysPermission (org.jeecg.modules.system.entity.SysPermission)16 JSONObject (com.alibaba.fastjson.JSONObject)8 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)8 Result (org.jeecg.common.api.vo.Result)8 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3