/** 获取角色对应菜单ID */ public void getAjaxRoleMenuIds() throws Exception { String menuIds = ""; HttpServletRequest request = ServletActionContext.getRequest(); String roleId = request.getParameter("role_id"); List list = basePermissionsManager.getAllPermis(false); List permisList = baseRoleManager.getRolePermis(roleId); if (list != null && !list.isEmpty()) { for (Iterator it = list.iterator(); it.hasNext(); ) { VBasePermissions basePermisView = (VBasePermissions) it.next(); String permis_id = basePermisView.getId(); // 循环得到角色标识对应菜单 if (permisList != null && !permisList.isEmpty()) { for (Iterator it2 = permisList.iterator(); it2.hasNext(); ) { TbBaseRolePermis tbBaseRolePermis = (TbBaseRolePermis) it2.next(); if (permis_id.equals(tbBaseRolePermis.getVcPermId())) { menuIds = menuIds + permis_id + ":"; } } } } } if (!"".equals(menuIds)) { menuIds = menuIds.substring(0, menuIds.lastIndexOf(":")); } Struts2Utils.renderText(menuIds); }
/** 列表显示页面 分页显示总行时有问题,分页还需要测试 */ public String list() throws Exception { HttpServletRequest request = Struts2Utils.getRequest(); rolesList = baseRoleManager.getAll(); // 获取所有角色 deptsList = baseDepartmentManager.getAll(); // 获取所有部门 request.setAttribute("rolesList", rolesList); request.setAttribute("deptsList", deptsList); // 设置角色标识,供页面保留查询条件使用 request.setAttribute("search_vcRoleNo", request.getParameter("vcRoleNo2")); // 设置部门标识,供页面保留查询条件使用 request.setAttribute("search_vcDeptNo", request.getParameter("filter_LIKE_vcDeptNo")); // 调用分页方法 this.setPaginationdataList(); logger.error("日志测试"); return INDEX; }
/** 打开权限树 */ public String openPermis() throws ServiceStartupException { HttpServletRequest request = Struts2Utils.getRequest(); String newrole_id = request.getParameter("role_id"); List listdata = baseRoleManager.getAll(); TbBaseUserInfo userInfo = baseUserInfoManager.get(id); List rolesIdList = null; if (Common.judgeString(newrole_id)) { rolesIdList = new ArrayList(); rolesIdList.add(newrole_id); } else { // 根据用户标识获取角色标识集合 rolesIdList = baseUserInfoManager.getRoles(userInfo.getId()); } request.setAttribute("rolesIdList", rolesIdList); request.setAttribute("listdata", listdata); request.setAttribute("userId", id); request.setAttribute("vcUserNo", userInfo.getId()); request.setAttribute("userName", entity == null ? "" : entity.getVcUserName()); return ACTION_FORWORD_USERPERMIS_LIST; }
/** * 获取部门和角色信息 * * @throws Exception */ public void getAjaxXmlData() throws Exception { deptsList = baseDepartmentManager.getAll(); // 获取所有部门 rolesList = baseRoleManager.getAll(); // 获取所有角色 String deptXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; if (deptsList != null && !deptsList.isEmpty()) { deptXml = deptXml + "<root>"; for (TbBaseDepartment dept : deptsList) { deptXml = deptXml + "<data>" + "<id>" + dept.getId() + "</id>" + "<name>" + dept.getVcDeptName() + "</name>" + "</data>"; } deptXml = deptXml + "</root>"; } String roleXml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; if (rolesList != null && !rolesList.isEmpty()) { roleXml = roleXml + "<root>"; for (TbBaseRoles role : rolesList) { roleXml = roleXml + "<data>" + "<id>" + role.getId() + "</id>" + "<name>" + role.getVcRolesName() + "</name>" + "</data>"; } roleXml = roleXml + "</root>"; } Struts2Utils.renderText(deptXml + "&&&" + roleXml); }