Search in sources :

Example 6 with SysPermission

use of org.jeecg.modules.system.entity.SysPermission in project kms by mahonelau.

the class SysPermissionServiceImpl method hasPermission.

@Override
public boolean hasPermission(String username, String url) {
    SysPermission sysPermission = new SysPermission();
    sysPermission.setUrl(url);
    int count = baseMapper.queryCountByUsername(username, sysPermission);
    if (count > 0) {
        return true;
    } else {
        return false;
    }
}
Also used : SysPermission(org.jeecg.modules.system.entity.SysPermission)

Example 7 with SysPermission

use of org.jeecg.modules.system.entity.SysPermission in project kms by mahonelau.

the class NgAlainServiceImpl method getJeecgMenu.

@Override
public JSONArray getJeecgMenu(String id) throws Exception {
    List<SysPermission> metaList = sysPermissionService.queryByUser(id);
    JSONArray jsonArray = new JSONArray();
    getPermissionJsonArray(jsonArray, metaList, null);
    JSONArray menulist = parseNgAlain(jsonArray);
    JSONObject jeecgMenu = new JSONObject();
    jeecgMenu.put("text", "jeecg菜单");
    jeecgMenu.put("group", true);
    jeecgMenu.put("children", menulist);
    JSONArray jeecgMenuList = new JSONArray();
    jeecgMenuList.add(jeecgMenu);
    return jeecgMenuList;
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) SysPermission(org.jeecg.modules.system.entity.SysPermission)

Example 8 with SysPermission

use of org.jeecg.modules.system.entity.SysPermission in project kms by mahonelau.

the class NgAlainServiceImpl method getPermissionJsonArray.

/**
 *  获取菜单JSON数组
 * @param jsonArray
 * @param metaList
 * @param parentJson
 */
private void getPermissionJsonArray(JSONArray jsonArray, List<SysPermission> metaList, JSONObject parentJson) {
    for (SysPermission permission : metaList) {
        if (permission.getMenuType() == null) {
            continue;
        }
        String tempPid = permission.getParentId();
        JSONObject json = getPermissionJsonObject(permission);
        if (parentJson == null && oConvertUtils.isEmpty(tempPid)) {
            jsonArray.add(json);
            if (!permission.isLeaf()) {
                getPermissionJsonArray(jsonArray, metaList, json);
            }
        } else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) {
            if (permission.getMenuType() == 0) {
                JSONObject metaJson = parentJson.getJSONObject("meta");
                if (metaJson.containsKey("permissionList")) {
                    metaJson.getJSONArray("permissionList").add(json);
                } else {
                    JSONArray permissionList = new JSONArray();
                    permissionList.add(json);
                    metaJson.put("permissionList", permissionList);
                }
            } else if (permission.getMenuType() == 1) {
                if (parentJson.containsKey("children")) {
                    parentJson.getJSONArray("children").add(json);
                } else {
                    JSONArray children = new JSONArray();
                    children.add(json);
                    parentJson.put("children", children);
                }
                if (!permission.isLeaf()) {
                    getPermissionJsonArray(jsonArray, metaList, json);
                }
            }
        }
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) JSONArray(com.alibaba.fastjson.JSONArray) SysPermission(org.jeecg.modules.system.entity.SysPermission)

Example 9 with SysPermission

use of org.jeecg.modules.system.entity.SysPermission 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 10 with SysPermission

use of org.jeecg.modules.system.entity.SysPermission 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

SysPermission (org.jeecg.modules.system.entity.SysPermission)59 JSONObject (com.alibaba.fastjson.JSONObject)22 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)22 TreeModel (org.jeecg.modules.system.model.TreeModel)16 Result (org.jeecg.common.api.vo.Result)14 JSONArray (com.alibaba.fastjson.JSONArray)10 HashMap (java.util.HashMap)9 Map (java.util.Map)9 JeecgBootException (org.jeecg.common.exception.JeecgBootException)9 CacheEvict (org.springframework.cache.annotation.CacheEvict)9 Transactional (org.springframework.transaction.annotation.Transactional)9 SysPermissionTree (org.jeecg.modules.system.model.SysPermissionTree)8 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 SysPermissionDataRule (org.jeecg.modules.system.entity.SysPermissionDataRule)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 LoginUser (org.jeecg.common.system.vo.LoginUser)2