Java Code Examples for org.jeecg.modules.system.entity.SysPermission#getParentId()
The following examples show how to use
org.jeecg.modules.system.entity.SysPermission#getParentId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysPermissionServiceImpl.java From teaching with Apache License 2.0 | 6 votes |
@Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) public void addPermission(SysPermission sysPermission) throws JeecgBootException { //---------------------------------------------------------------------- //判断是否是一级菜单,是的话清空父菜单 if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) { sysPermission.setParentId(null); } //---------------------------------------------------------------------- String pid = sysPermission.getParentId(); if(oConvertUtils.isNotEmpty(pid)) { //设置父节点不为叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 0); } sysPermission.setCreateTime(new Date()); sysPermission.setDelFlag(0); sysPermission.setLeaf(true); this.save(sysPermission); }
Example 2
Source File: SysPermissionServiceImpl.java From jeecg-boot-with-activiti with MIT License | 6 votes |
/** * 真实删除 */ @Override @Transactional @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) public void deletePermission(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); if(oConvertUtils.isNotEmpty(pid)) { int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } } sysPermissionMapper.deleteById(id); // 该节点可能是子节点但也可能是其它节点的父节点,所以需要级联删除 this.removeChildrenBy(sysPermission.getId()); }
Example 3
Source File: SysPermissionServiceImpl.java From jeecg-boot with Apache License 2.0 | 6 votes |
/** * 逻辑删除 */ @Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) //@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2") public void deletePermissionLogical(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } sysPermission.setDelFlag(1); this.updateById(sysPermission); }
Example 4
Source File: SysPermissionController.java From jeecg-boot-with-activiti with MIT License | 6 votes |
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); } } } }
Example 5
Source File: SysRoleController.java From jeecg-boot with Apache License 2.0 | 6 votes |
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); } } } }
Example 6
Source File: SysPermissionServiceImpl.java From jeecg-cloud with Apache License 2.0 | 6 votes |
/** * 逻辑删除 */ @Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) //@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2") public void deletePermissionLogical(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } sysPermission.setDelFlag(1); this.updateById(sysPermission); }
Example 7
Source File: SysPermissionServiceImpl.java From teaching with Apache License 2.0 | 6 votes |
/** * 逻辑删除 */ @Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) //@CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true,condition="#sysPermission.menuType==2") public void deletePermissionLogical(String id) throws JeecgBootException { SysPermission sysPermission = this.getById(id); if(sysPermission==null) { throw new JeecgBootException("未找到菜单信息"); } String pid = sysPermission.getParentId(); int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid)); if(count==1) { //若父节点无其他子节点,则该父节点是叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 1); } sysPermission.setDelFlag(1); this.updateById(sysPermission); }
Example 8
Source File: SysDepartPermissionController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
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); } } } }
Example 9
Source File: SysRoleController.java From teaching with Apache License 2.0 | 6 votes |
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); } } } }
Example 10
Source File: SysPermissionController.java From jeecg-cloud with Apache License 2.0 | 6 votes |
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); } } } }
Example 11
Source File: SysPermissionController.java From jeecg-boot with Apache License 2.0 | 6 votes |
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); } } } }
Example 12
Source File: SysPermissionServiceImpl.java From jeecg-boot with Apache License 2.0 | 5 votes |
@Override @CacheEvict(value = CacheConstant.SYS_DATA_PERMISSIONS_CACHE,allEntries=true) public void editPermission(SysPermission sysPermission) throws JeecgBootException { SysPermission p = this.getById(sysPermission.getId()); //TODO 该节点判断是否还有子节点 if(p==null) { throw new JeecgBootException("未找到菜单信息"); }else { sysPermission.setUpdateTime(new Date()); //---------------------------------------------------------------------- //Step1.判断是否是一级菜单,是的话清空父菜单ID if(CommonConstant.MENU_TYPE_0.equals(sysPermission.getMenuType())) { sysPermission.setParentId(""); } //Step2.判断菜单下级是否有菜单,无则设置为叶子节点 int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, sysPermission.getId())); if(count==0) { sysPermission.setLeaf(true); } //---------------------------------------------------------------------- this.updateById(sysPermission); //如果当前菜单的父菜单变了,则需要修改新父菜单和老父菜单的,叶子节点状态 String pid = sysPermission.getParentId(); if((oConvertUtils.isNotEmpty(pid) && !pid.equals(p.getParentId())) || oConvertUtils.isEmpty(pid)&&oConvertUtils.isNotEmpty(p.getParentId())) { //a.设置新的父菜单不为叶子节点 this.sysPermissionMapper.setMenuLeaf(pid, 0); //b.判断老的菜单下是否还有其他子菜单,没有的话则设置为叶子节点 int cc = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, p.getParentId())); if(cc==0) { if(oConvertUtils.isNotEmpty(p.getParentId())) { this.sysPermissionMapper.setMenuLeaf(p.getParentId(), 1); } } } } }
Example 13
Source File: SysPermissionTree.java From jeecg-cloud with Apache License 2.0 | 5 votes |
public SysPermissionTree(SysPermission permission) { this.key = permission.getId(); this.id = permission.getId(); this.perms = permission.getPerms(); this.permsType = permission.getPermsType(); this.component = permission.getComponent(); this.createBy = permission.getCreateBy(); this.createTime = permission.getCreateTime(); this.delFlag = permission.getDelFlag(); this.description = permission.getDescription(); this.icon = permission.getIcon(); this.isLeaf = permission.isLeaf(); this.menuType = permission.getMenuType(); this.name = permission.getName(); this.parentId = permission.getParentId(); this.sortNo = permission.getSortNo(); this.updateBy = permission.getUpdateBy(); this.updateTime = permission.getUpdateTime(); this.redirect = permission.getRedirect(); this.url = permission.getUrl(); this.hidden = permission.isHidden(); this.route = permission.isRoute(); this.keepAlive = permission.isKeepAlive(); this.alwaysShow= permission.isAlwaysShow(); /*update_begin author:wuxianquan date:20190908 for:赋值 */ this.internalOrExternal = permission.isInternalOrExternal(); /*update_end author:wuxianquan date:20190908 for:赋值 */ this.title=permission.getName(); if (!permission.isLeaf()) { this.children = new ArrayList<SysPermissionTree>(); } this.status = permission.getStatus(); }
Example 14
Source File: SysPermissionController.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * 查询子菜单 * * @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()); } }
Example 15
Source File: SysPermissionController.java From jeecg-cloud with Apache License 2.0 | 5 votes |
/** * 查询子菜单 * * @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()); } }
Example 16
Source File: SysPermissionTree.java From jeecg-boot-with-activiti with MIT License | 5 votes |
public SysPermissionTree(SysPermission permission) { this.key = permission.getId(); this.id = permission.getId(); this.perms = permission.getPerms(); this.permsType = permission.getPermsType(); this.component = permission.getComponent(); this.createBy = permission.getCreateBy(); this.createTime = permission.getCreateTime(); this.delFlag = permission.getDelFlag(); this.description = permission.getDescription(); this.icon = permission.getIcon(); this.isLeaf = permission.isLeaf(); this.menuType = permission.getMenuType(); this.name = permission.getName(); this.parentId = permission.getParentId(); this.sortNo = permission.getSortNo(); this.updateBy = permission.getUpdateBy(); this.updateTime = permission.getUpdateTime(); this.redirect = permission.getRedirect(); this.url = permission.getUrl(); this.hidden = permission.isHidden(); this.route = permission.isRoute(); this.keepAlive = permission.isKeepAlive(); this.alwaysShow= permission.isAlwaysShow(); /*update_begin author:wuxianquan date:20190908 for:赋值 */ this.internalOrExternal = permission.isInternalOrExternal(); /*update_end author:wuxianquan date:20190908 for:赋值 */ this.title=permission.getName(); if (!permission.isLeaf()) { this.children = new ArrayList<SysPermissionTree>(); } this.status = permission.getStatus(); }
Example 17
Source File: TreeModel.java From jeecg-boot-with-activiti with MIT License | 5 votes |
public TreeModel(SysPermission permission) { this.key = permission.getId(); this.icon = permission.getIcon(); this.parentId = permission.getParentId(); this.title = permission.getName(); this.slotTitle = permission.getName(); this.value = permission.getId(); this.isLeaf = permission.isLeaf(); this.label = permission.getName(); if(!permission.isLeaf()) { this.children = new ArrayList<TreeModel>(); } }
Example 18
Source File: SysPermissionController.java From teaching with Apache License 2.0 | 5 votes |
/** * 查询子菜单 * * @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()); } }
Example 19
Source File: SysPermissionController.java From jeecg-boot with Apache License 2.0 | 4 votes |
/** * 获取菜单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(json==null) { continue; } 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"))) { // 类型( 0:一级菜单 1:子菜单 2:按钮 ) if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) { 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); } // 类型( 0:一级菜单 1:子菜单 2:按钮 ) } else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_1) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_0)) { 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); } } } } }
Example 20
Source File: NgAlainServiceImpl.java From jeecg-boot with Apache License 2.0 | 4 votes |
/** * 获取菜单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); } } } } }