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;
}
}
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;
}
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);
}
}
}
}
}
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;
}
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);
}
}
}
}
Aggregations