@Transactional public void deleteById(Long appId) { if (appId != null && appId > 0) { sysAccessMapper.deleteSysAccessByAppId(appId); sysApplicationMapper.deleteSysApplicationById(appId); SysApplication app = this.getSysApplication(appId); if (app != null) { sysTreeMapper.deleteSysTreeById(app.getNodeId()); } } }
/** * 获取某个分类下的全部分类节点 * * @param parentId 父节点编号 * @return */ public List<TreeModel> getTreeModels(long parentId) { List<TreeModel> treeModels = new java.util.ArrayList<TreeModel>(); TreeModel root = sysTreeService.findById(parentId); SysTreeQuery query = new SysTreeQuery(); query.treeIdLike(root.getTreeId() + "%"); List<SysTree> trees = sysTreeMapper.getSysTrees(query); if (trees != null && !trees.isEmpty()) { for (SysTree tree : trees) { treeModels.add(tree); } } treeModels.remove(root); return treeModels; }
public JSONArray getUserMenu(long parent, String actorId) { JSONArray array = new JSONArray(); SysUser user = authorizeService.login(actorId); if (user != null) { List<SysTree> treeList = null; SysApplication app = this.findById(parent); SysTreeQuery query = new SysTreeQuery(); query.treeId(app.getNode().getTreeId()); query.treeIdLike(app.getNode().getTreeId() + "%"); if (!user.isSystemAdmin()) { List<String> actorIds = new java.util.ArrayList<String>(); List<Object> rows = entityService.getList("getAgents", actorId); if (rows != null && !rows.isEmpty()) { for (Object object : rows) { if (object instanceof Agent) { Agent agent = (Agent) object; if (!agent.isValid()) { continue; } switch (agent.getAgentType()) { case 0: // 全局代理 actorIds.add(agent.getAssignFrom()); break; default: break; } } } } if (!actorIds.isEmpty()) { actorIds.add(actorId); query.setActorIds(actorIds); } else { query.setActorId(actorId); } treeList = sysTreeMapper.getTreeListByUsers(query); } else { treeList = sysTreeMapper.getTreeList(query); } List<TreeModel> treeModels = new java.util.ArrayList<TreeModel>(); for (SysTree tree : treeList) { if (StringUtils.isNotEmpty(tree.getUrl())) { if (StringUtils.startsWith(tree.getUrl(), "/")) { if (StringUtils.isNotEmpty(SystemConfig.getServiceUrl())) { String link = SystemConfig.getServiceUrl() + tree.getUrl(); tree.setUrl(link); } else { String link = ApplicationContext.getContextPath() + tree.getUrl(); tree.setUrl(link); } } } treeModels.add(tree); } TreeHelper treeHelper = new TreeHelper(); array = treeHelper.getTreeJSONArray(treeModels); // logger.debug(array.toString('\n')); } return array; }