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