`

三级菜单树的组装与遍历显示

阅读更多
Action:
UserManagerAction.java
树工具类.
TreeUtil.java
三级菜单形如:

具体加载数据:
PS:TreeUtil可以对菜单无限级装填.
详见->menus的List-Map数据格式.zip

页面:
left.jsp
显示效果:
直接加载,展开


再点击,关闭.



1.
UserManagerAction.java 参见menusInfo()方法.
package com.lecheng.pcaction;

import io.rong.api.ApiHttpClient;
import io.rong.models.FormatType;
import io.rong.models.SdkHttpResult;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.lecheng.entity.manager_entity;
import com.lecheng.entity.user_entity;
import com.lecheng.entity.menu.MenuInfo;
import com.lecheng.framework.filter.init.BaseConf;
import com.lecheng.serviceimpl.SchoolManagerServiceImpl;
import com.lecheng.serviceimpl.SystemLogServiceImpl;
import com.lecheng.serviceimpl.UserManagerServiceImpl;
import com.lecheng.serviceimpl.menu.MenuInfoServiceImpl;
import com.lecheng.services.PaymentService;
import com.lecheng.services.SchoolManagerService;
import com.lecheng.services.SystemLogService;
import com.lecheng.services.UserManagerService;
import com.lecheng.services.menu.MenuInfoService;
import com.lecheng.utils.BaseAction;
import com.lecheng.utils.CommonUtils;
import com.lecheng.utils.DesEncrypt;
import com.lecheng.utils.TreeUtil;
import com.lecheng.utils.link_db;

/**
 * 用户管理action
 * @author lengzl
 * @email 819681951@qq.com
 * @create 2017年1月12日 上午10:23:14
 */
public class UserManagerAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1426884653078966867L;
	private Map<String, Object> dataMap;
	private HttpServletRequest request = ServletActionContext.getRequest();
	private HttpServletResponse response = ServletActionContext.getResponse();
	private HttpSession session = request.getSession();
	SystemLogServiceImpl systemLog = new SystemLogService();
	SdkHttpResult result = null;
	private MenuInfoService menuInfoService = new MenuInfoServiceImpl();
	
	//======lengzl新加===============================================================================
	
	
	public Map<String, Object> getDataMap() {
		return this.dataMap;
	}

	public void setDataMap(Map<String, Object> dataMap) {
		this.dataMap = dataMap;
	}
	
	
	
	/**
	 * 管理员登录
	 * <pre>
	 *  * 版本修改历史记录:
     * 1)  初始创建 未知
     * </pre>
     * 2) 2017年1月5日 下午1:29:31 获取当前用户所有的功能权限.
     * 
	 * @throws Exception 
	 */
	@SuppressWarnings("unchecked")
	public String MangerLogin() throws Exception {
		dataMap = new HashMap<String, Object>();
		String username = this.request.getParameter("username");
		String password = this.request.getParameter("password");
		String type = this.request.getParameter("type");
		String m = "1";
		String content = "";
		UserManagerServiceImpl umanager = new UserManagerService();
		password = DesEncrypt.encryptDES(password, CommonUtils.encryptKey);
		ArrayList<manager_entity> res = umanager.adminLogin(username, password,
				type);
		if (res != null && res.size() > 0) {
			dataMap.put("result", "success");
			dataMap.put("message", "登录成功");
			dataMap.put("msg", res);
			session.setAttribute("username", username);
			session.setAttribute("usertype", type);
			session.setAttribute("schoolid", res.get(0).getSchoolid());
			session.setAttribute("schoolname", res.get(0).getSchoolname());
			session.setAttribute("areaid", res.get(0).getAreaid());
			session.setAttribute("userid", res.get(0).getUserid());
			session.setAttribute("classid", res.get(0).getClassid());
			session.setAttribute("schoolareaid", res.get(0).getSchoolareaid());
			session.setAttribute("rootPath", request.getSession().getServletContext().getRealPath(""));
			session.setAttribute("m", m);
			manager_entity currUser= res.get(0);
			session.setAttribute("curuser", currUser);
			String functions = umanager.getFuncIDs(currUser.getRoleIds());
			if(StringUtils.isNotEmpty(functions)){
				session.setAttribute("funcIds", functions);
				String[] functionsArray = functions.split(",");  //未使用.
				/*[, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 607, 608, 801, 802, 
				 804, 3301, 3302, 3303, 805, 1701, 1702, 1703, 1704,1705, 2301, 2302, 2303, 2304, 
				 2305, 2306, 2307, 2308, 2501, 2502, 201, 202, 203, 402, 1258, 1, 405, 1003, 1008, 
				 1009, 1010, 1011, 2105, 4901, 1004, 1201, 1202, 1203, 1204, 1801, 1802, 1005, 2103, 
				 2104, 1006, 1205, 1206, 1207, 1208, 1007, 1209, 1210, 1211, 1212, 1213, 1214, 1215,
				 1901, 1904, 2106, 1216, 1220, 1221, 1222, 1218, 2101, 2102, 2901, 3901, 406, 1001, 1002]*/
				//供应商跳转的页面. etc
			}
			
			/**
			 * 添加系统日志
			 */
			if(type.equals(CommonUtils.userTypeForAdmin)){
				content = "系统管理员";
			}if(type.equals(CommonUtils.userTypeForParkAdmin)){
				content = "学校管理员";
			}if(type.equals(CommonUtils.userTypeForCityAdmin)){
				content = "市教育局管理员";
			}if(type.equals(CommonUtils.userTypeForAreaAdmin)){
				content = "区县教育局管理员";
			}
			systemLog.addSystemLog(CommonUtils.operation_class_login, request.getRemoteAddr(), content+"登录", username);
			
		} else {
			dataMap.put("result", "faild");
			dataMap.put("message", "用户名或密码错误");
		}
		return SUCCESS;
	}

	public String parentLogin() {

		dataMap = new HashMap<String, Object>();
		String username = this.request.getParameter("username");
		String password = this.request.getParameter("password");
		String type = this.request.getParameter("type");
		String m = "0";
		UserManagerServiceImpl umanager = new UserManagerService();
		ArrayList<manager_entity> res = umanager.adminLogin(username, password,
				type);
		if (res != null && res.size() > 0) {

			session.setAttribute("username", username);
			session.setAttribute("usertype", type);
			session.setAttribute("schoolid", res.get(0).getSchoolid());
			session.setAttribute("schoolname", res.get(0).getSchoolname());
			session.setAttribute("areaid", res.get(0).getAreaid());
			session.setAttribute("userid", res.get(0).getUserid());
			session.setAttribute("classid", res.get(0).getClassid());
			session.setAttribute("m", m);
			dataMap.put("result", "success");
			dataMap.put("message", "登录成功");
			try {
				response.sendRedirect("adminpages/main_parent.jsp");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		} else {

			try {
				response.sendRedirect("http://youyitong365.com/login.html");
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			dataMap.put("result", "faild");
			dataMap.put("message", "用户名或密码错误");
		}
		return SUCCESS;
	}

	/*
	 * 用户统计
	 */
	public String getUserState() {
		dataMap = new HashMap<String, Object>();
		UserManagerServiceImpl umanager = new UserManagerService();
		dataMap.put("result", "success");
		dataMap.put("message", umanager.getUserState());
		return SUCCESS;
	}

	/*
	 * 获取园区管理员 列表
	 */
	public String getYuanquanManagerList() {
		dataMap = new HashMap<String, Object>();
		String schoolid = this.request.getParameter("schoolid");
		UserManagerServiceImpl umanager = new UserManagerService();
		dataMap.put("result", "success");
		dataMap.put("message", umanager.getSubManagerList(schoolid, "4"));
		return SUCCESS;
	}

	/**
	 * 添加园区管理员
	 */
	public String addYuanquManager() {
		dataMap = new HashMap<String, Object>();
		String username = this.request.getParameter("username");
		String password = this.request.getParameter("password");
		String schoolid = this.request.getParameter("schoolid");
		UserManagerServiceImpl umanager = new UserManagerService();
		umanager.addSchoolManager(username, password, schoolid, "", "");
		dataMap.put("result", "success");
		dataMap.put("message", "添加成功");
		return SUCCESS;
	}

	/**
	 * 添加业务人员
	 */
	public String addBusiness() {
		dataMap = new HashMap<String, Object>();
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		String nickname = request.getParameter("nickname");
		String sex = request.getParameter("sex");
		String tel = request.getParameter("tel");
		String area = request.getParameter("area");
		UserManagerServiceImpl umanager = new UserManagerService();

		if (umanager.addBusiness(username, password, nickname, sex, area, tel)) {
			dataMap.put("result", "success");
			dataMap.put("msg", "添加成功");
		} else {
			dataMap.put("msg", "添加失败");
		}

		return SUCCESS;
	}

	/**
	 * 获取业务人员列表
	 */
	public String getBusinessList() {
		dataMap = new HashMap<String, Object>();
		String usertype = this.request.getParameter("usertype");
		String account = this.request.getParameter("account");
		String pageindex = request.getParameter("pageindex");
		String pagesize = request.getParameter("pagesize");
		if (account == null) {
			account = "";
		}
		UserManagerServiceImpl umanager = new UserManagerService();
		int pagequeryIndex = Integer.parseInt(pageindex)
				* Integer.parseInt(pagesize);
		int queryPageSize = Integer.parseInt(pagesize);
		int counts = umanager.getBusinessCount(usertype, account);
		int allpagesize = (int) Math.ceil((double) counts
				/ (double) queryPageSize);
		dataMap.put("counts", counts);
		dataMap.put("allpagesize", allpagesize);
		dataMap.put("msg", umanager.getBusinessList(usertype, account,
				pagequeryIndex, queryPageSize));
		dataMap.put("result", "success");
		return SUCCESS;
	}

	/*
	 * 获取代理列表
	 */
	public String getDailiList() {
		String usertype = this.request.getParameter("usertype");
		String areaid = this.request.getParameter("areaid");
		String pageNum = request.getParameter("pageNum");
		String pageSize = request.getParameter("pageSize");
		dataMap = new HashMap<String, Object>();
		UserManagerServiceImpl umanager = new UserManagerService();
		List<manager_entity> l = umanager.getDailiList(usertype, areaid);
		List<manager_entity> rl = new ArrayList<>();
		int pn = Integer.parseInt(pageNum);
		int ps = Integer.parseInt(pageSize);
		if (pn > 0) {
			dataMap.put("haspre", true);
		} else {
			dataMap.put("haspre", false);
		}
		if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) {
			dataMap.put("hasnext", true);
		} else {
			dataMap.put("hasnext", false);
		}
		if (l.size() >= (pn + 1) * ps) {
			rl = l.subList(pn * ps, (pn + 1) * ps);
		} else {
			rl = l.subList(pn * ps, l.size());
		}
		dataMap.put("total", l.size());
		dataMap.put("result", "success");
		dataMap.put("message", rl);
		return SUCCESS;
	}

	/**
	 * 添加管理员
	 * @throws Exception 
	 */
	public String addDaili() throws Exception {
		dataMap = new HashMap<String, Object>();
		String areaid = this.request.getParameter("areaid");
		String username = this.request.getParameter("username");
		String password = this.request.getParameter("password");
		password = DesEncrypt.encryptDES(password, CommonUtils.encryptKey);
		String usertype = this.request.getParameter("usertype");
		UserManagerServiceImpl umanager = new UserManagerService();
		umanager.addDaili(username, password, areaid, usertype);
		dataMap.put("result", "success");
		dataMap.put("message", "添加成功");
		return SUCCESS;
	}

	/**
	 * 删除管理员
	 */
	public String deleteManager() {
		dataMap = new HashMap<String, Object>();
		String userid = this.request.getParameter("userid");
		UserManagerServiceImpl umanager = new UserManagerService();
		umanager.delelteManager(userid);
		dataMap.put("result", "success");
		dataMap.put("message", "删除成功");
		return SUCCESS;
	}

	/**
	 * 幼儿园添加家长
	 */
	public String addparents() {

		this.dataMap = new HashMap<String, Object>();
		UserManagerServiceImpl usermanagerService = new UserManagerService();
		SchoolManagerServiceImpl schoolManager = new SchoolManagerService();
		String schoolid = request.getParameter("schoolid");
		String phonenunm = request.getParameter("phonenunm");
		String parentname = request.getParameter("parentname");
		String relationselect = request.getParameter("relationselect");
		String idCard = request.getParameter("idCard");
		int babyid = usermanagerService.getMaxBabyId();
		String watchendttime = schoolManager.getSchoolName(schoolid).getAddtime();
		// -------宝宝冲会员状态在相关联的家长数据中,所以再次新增家长取其他家长的会员日期-----
		PaymentService paymentService = new PaymentService();
		Map<String, String> params = new HashMap<>();
		params.put("babyid", request.getParameter("babyid"));
		Map<String, Object> parentResult = paymentService.gotParentsByBabyId(params);
		if ("success".equals(parentResult.get("result"))) {
			List<Map<String, Object>> parents = (List<Map<String, Object>>) parentResult.get("parents");
			if (CollectionUtils.isNotEmpty(parents)) {
				watchendttime = MapUtils.getString(parents.get(0), "watchendttime");
			}
		}
		// -------取其他家长的会员日期--------------
		int count = usermanagerService.getPaeretCountByUserName(phonenunm);
		String userpassword = "";
		if(count!=0){
			userpassword = usermanagerService.getUserInfo(phonenunm).getUserpassword();
			String groupId = usermanagerService.getBabyInfo(String.valueOf(babyid)).getClasschatroomid();
			String groupName = usermanagerService.getBabyInfo(String.valueOf(babyid)).getClassname();
			// 加入群组
			try {
				result = ApiHttpClient.joinGroup(
						CommonUtils.rongAppKey,
						CommonUtils.rongAppSecret, phonenunm,
						groupId, groupName, FormatType.json);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		if (usermanagerService.addParents(phonenunm,parentname,CommonUtils.parent,relationselect,idCard,babyid,watchendttime,userpassword)) {
			dataMap.put("msg", "添加成功");
			dataMap.put("result", "success");
			/**
			 * 系统日志
			 */
			systemLog.addSystemLog(CommonUtils.operation_class_add, request.getRemoteAddr(), "新增家长【"+parentname+"】", request.getSession().getAttribute("username").toString());
			
		} else {
			dataMap.put("msg", "添加失败");
			dataMap.put("result", "faild");
		}
		return SUCCESS;
	}
	public String addUser() {

		this.dataMap = new HashMap<String, Object>();
		UserManagerServiceImpl usermanagerService = new UserManagerService();
		SchoolManagerServiceImpl schoolManager = new SchoolManagerService();
		String schoolid = this.request.getParameter("schoolid");
		String phonenunm = this.request.getParameter("phonenunm");
		String parentname = this.request.getParameter("parentname");
		String relationselect = this.request.getParameter("relationselect");
		String idCard = this.request.getParameter("idCard");
		int babyid = Integer.parseInt(this.request.getParameter("babyid"));
		String watchendttime = schoolManager.getSchoolName(schoolid).getAddtime();
		// -------宝宝冲会员状态在相关联的家长数据中,所以再次新增家长取其他家长的会员日期-----
		PaymentService paymentService = new PaymentService();
		Map<String, String> params = new HashMap<>();
		params.put("babyid", request.getParameter("babyid"));
		Map<String, Object> parentResult = paymentService.gotParentsByBabyId(params);
		if ("success".equals(parentResult.get("result"))) {
			List<Map<String, Object>> parents = (List<Map<String, Object>>) parentResult.get("parents");
			if (CollectionUtils.isNotEmpty(parents)) {
				watchendttime = MapUtils.getString(parents.get(0), "watchendttime");
			}
		}
		// -------取其他家长的会员日期--------------
		int count = usermanagerService.getPaeretCountByUserName(phonenunm);
		String userpassword = "";
		
		if(phonenunm==null){
			phonenunm = "";
		}if(parentname==null){
			parentname = "";
		}
		if(count!=0){
			userpassword = usermanagerService.getUserInfo(phonenunm).getUserpassword();
		}if (usermanagerService.addParents(phonenunm,parentname,CommonUtils.parent,relationselect,idCard,babyid,watchendttime,userpassword)) {
			dataMap.put("msg", "添加成功");
			dataMap.put("result", "success");
			String username = request.getSession().getAttribute("username").toString();
			
			if(StringUtils.isNotBlank(username))
				systemLog.addSystemLog(CommonUtils.operation_class_add, request.getRemoteAddr(), "新增家长【" + parentname + "】", username);

		} else {
			dataMap.put("msg", "添加失败");
			dataMap.put("result", "faild");
		}
		return SUCCESS;
	}

	/**
	 * 添加教师
	 */
	public String addTeacher() {
		dataMap = new HashMap<String, Object>();
		final String username = this.request.getParameter("username");
		//String password = this.request.getParameter("password");
		String schoolid = this.request.getParameter("schoolid");
		String schoolname = this.request.getParameter("schoolname");
		String idCard = this.request.getParameter("idCard");
		final String classid = this.request.getParameter("classid");
		String nickname = this.request.getParameter("nickname");
		String sex = this.request.getParameter("sex");
		UserManagerServiceImpl usermanager = new UserManagerService();
		int count = usermanager.getPaeretCountByUserName(username);
		String password = "";
		if(count!=0){
			password = usermanager.getUserInfo(username).getUserpassword();
		}
		if (usermanager.adduser(username, password, "1", schoolid, schoolname,
				"", nickname, classid, "", sex,idCard) == 1) {
			
			dataMap.put("result", "success");
			dataMap.put("message", "添加成功");
			/**
			 * 异步处理
			 */
			/*Thread thread = new Thread(new Runnable() {
				
				public void run() {
					// TODO Auto-generated method stub
					try {
						TimeUnit.SECONDS.sleep(1);
						IMmanagerUtil.addUser(username, "123456");
						IMmanagerUtil.updateMemberOfOldClass(username, classid);
						
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
						
				}
				
			});
			thread.start();*/
		} else {
			dataMap.put("result", "faild");
			dataMap.put("message", "该教师已经存在");
		}

		return SUCCESS;
	}

	/**
	 * 编辑教师
	 */
	public String updateTeacher() {
		dataMap = new HashMap<String, Object>();

		String userid = this.request.getParameter("userid");
		final String username = this.request.getParameter("username");
		//IMmanagerUtil.deleteMemberOfOldClass(userid,CommonUtils.teacher);
		String password = this.request.getParameter("password");
		String nickname = this.request.getParameter("nickname");
		String oldUserName = this.request.getParameter("oldUserName");
		String sex = this.request.getParameter("sex");
		String idCard = this.request.getParameter("idCard");
		final String classid = this.request.getParameter("classid");
		UserManagerServiceImpl usermanager = new UserManagerService();
		if (usermanager.updateTeacher(userid, username, password, nickname,sex, classid,idCard)) {
			dataMap.put("result", "success");
			dataMap.put("message", "修改成功");
			
			if (password != null && password.length() != 0) {
				// 退出群组
				String schoolroom = usermanager.getTeacherInfo(userid, CommonUtils.teacher)
						.getSchoolroom();
				String[] schoolGroupId = schoolroom.split(",");
				String classGroupId = usermanager.getTeacherInfo(userid, CommonUtils.teacher)
						.getClasschatroomid();
				String classname = usermanager.getTeacherInfo(userid, CommonUtils.teacher)
						.getClassname();
				String schoolname = usermanager.getTeacherInfo(userid, CommonUtils.teacher)
						.getSchoolname();
				try {
					result = ApiHttpClient.quitGroup(CommonUtils.rongAppKey,
							CommonUtils.rongAppSecret, oldUserName,
							classGroupId, FormatType.json);

					result = ApiHttpClient.joinGroup(CommonUtils.rongAppKey,
							CommonUtils.rongAppSecret, username, classGroupId,
							classname, FormatType.json);

					for (int i = 0; i < schoolGroupId.length; i++) {

						result = ApiHttpClient.quitGroup(
								CommonUtils.rongAppKey,
								CommonUtils.rongAppSecret, oldUserName,
								schoolGroupId[i], FormatType.json);

						result = ApiHttpClient.joinGroup(
								CommonUtils.rongAppKey,
								CommonUtils.rongAppSecret, username,
								schoolGroupId[i], schoolname, FormatType.json);

					}
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			
			/**
			 * 异步处理
			 */
			/*Thread thread = new Thread(new Runnable() {
				
				public void run() {
					// TODO Auto-generated method stub
					try {
						TimeUnit.SECONDS.sleep(1);
						IMmanagerUtil.updateMemberOfOldClass(username, classid);
						
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
						
				}
				
			});
			thread.start();*/
		} else {
			dataMap.put("result", "faild");
			dataMap.put("message", "修改失败");
		}
		return SUCCESS;
	}

	/**
	 * 根据学校ID获取教师列表
	 */
	public String getTeachersList() {
		dataMap = new HashMap<String, Object>();
		String schoolid = this.request.getParameter("schoolid");
		String account = this.request.getParameter("account");
		String other = this.request.getParameter("other");
		String pageindex = request.getParameter("pageindex");
		String pagesize = request.getParameter("pagesize");
		String time = "";
		if (pageindex == null || pageindex.length() == 0) {
			dataMap.put("result", "faild");
			dataMap.put("message", "请输入页码");
		}
		if (pagesize == null || pagesize.length() == 0) {
			dataMap.put("result", "faild");
			dataMap.put("message", "请输入每页显示数量");
		}
		if (account == null || account.length() == 0) {

			account = "";
		}

		UserManagerServiceImpl usermanager = new UserManagerService();
		dataMap.put("result", "success");

		int pagequeryIndex = Integer.parseInt(pageindex)
				* Integer.parseInt(pagesize);
		int queryPageSize = Integer.parseInt(pagesize);

		ArrayList<user_entity> teacherlist = usermanager.getUserListBySchoolid(
				pagequeryIndex, queryPageSize, schoolid, "1", account, other,
				time);
		int counts = usermanager.getTeacherCount(schoolid, "1", account, other,
				time);
		ArrayList<user_entity> copylist = new ArrayList<user_entity>();
		int allpagesize = (int) Math.ceil((double) counts/ (double) queryPageSize);
		dataMap.put("result", "success");
		dataMap.put("counts", counts);
		dataMap.put("allpagesize", allpagesize);

		for (user_entity ue : teacherlist) {
			String userid = ue.getUserid();
			String sql1 = "select * from table_babycomment where teacherid='"
					+ userid + "'";
			String sql2 = "select * from table_trends where userid='" + userid
					+ "'";
			int commentnum;
			try {
				commentnum = link_db.getInstance().executeQuery_noobj(sql1);
				int notinum = link_db.getInstance().executeQuery_noobj(sql2);
				ue.setDianpingshu(commentnum + "");
				ue.setBangjitongzhi(notinum + "");
				copylist.add(ue);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
		dataMap.put("message", copylist);
		return SUCCESS;
	}

	/**
	 * 根据班级获取家长列表
	 */
	public String getParentListByClassid() {
		
		dataMap = new HashMap<String, Object>();
		String classid = this.request.getParameter("classid");
		String account = this.request.getParameter("account");
		String other = this.request.getParameter("other");
		String schoolid = (String) request.getSession()
				.getAttribute("schoolid");
		String adminSchoolid = this.request.getParameter("adminSchoolid");
		String pageindex = request.getParameter("pageindex");
		String pagesize = request.getParameter("pagesize");
		String userType = (String) request.getSession()
				.getAttribute("usertype"); //

		if (pageindex == null || pageindex.length() == 0) {

			dataMap.put("result", "faild");
			dataMap.put("message", "请输入页码");
		}
		if (pagesize == null || pagesize.length() == 0) {

			dataMap.put("result", "faild");
			dataMap.put("message", "请输入每页显示数量");
		}

		if (account == null || account.length() == 0) {
			account = "";
		}

		UserManagerServiceImpl usermanager = new UserManagerService();
		dataMap.put("result", "success");

		int pagequeryIndex = Integer.parseInt(pageindex)
				* Integer.parseInt(pagesize);
		int queryPageSize = Integer.parseInt(pagesize);
		int counts = 0;
		int allpagesize; //userType=3系统管理员
		if (userType.equals(CommonUtils.userTypeForAdmin) //权限管理判断用户是否是管理员.学校管理员or业务员的权限. LLD.走这
				|| userType.equals(CommonUtils.business)) {
			
			dataMap.put("message", usermanager
					.getUserListByClassid(pagequeryIndex, queryPageSize,
							classid, CommonUtils.parent, account,
							adminSchoolid, CommonUtils.userTypeForAdmin, other));
			
			counts = usermanager
					.getPaeretCount(classid, CommonUtils.parent, account,
							adminSchoolid, CommonUtils.userTypeForAdmin, other);

		} else {
			dataMap.put("message", usermanager.getUserListByClassid(
					pagequeryIndex, queryPageSize, classid, CommonUtils.parent, //0家长
					account, schoolid, CommonUtils.userTypeForParkAdmin,
					CommonUtils.all));

			counts = usermanager.getPaeretCount(classid, CommonUtils.parent,
					account, schoolid, CommonUtils.userTypeForParkAdmin,
					CommonUtils.all);
		}
		allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize);
		dataMap.put("result", "success");
		dataMap.put("counts", counts);
		dataMap.put("allpagesize", allpagesize);
		return SUCCESS;
	}

	/*
	 * 获取幼儿园列表
	 */
	public String getYuanquanList() {

		// String schoolid=
		return SUCCESS;
	}

	/**
	 * 设置家长视频观看时间
	 */
	public String setParentWatchTime() {
		dataMap = new HashMap<String, Object>();
		String starttime = this.request.getParameter("starttime");
		String endtime = this.request.getParameter("endtime");
		String userid = this.request.getParameter("userid");
		//IMmanagerUtil.deleteMemberOfOldClass(userid,CommonUtils.parent);
		String childname = this.request.getParameter("childname");
		String selectsex = this.request.getParameter("selectsex");
		String demo = this.request.getParameter("demo");
		String selectclass = this.request.getParameter("selectclass");
		String relationselect = this.request.getParameter("relationselect");
		String parentname = this.request.getParameter("parentname");
		String phonenunm = this.request.getParameter("phonenunm");
		String idCard = this.request.getParameter("idCard");
		String userpassword = this.request.getParameter("userpassword");
		String oldUserName = this.request.getParameter("oldUserName");
		UserManagerServiceImpl usermanager = new UserManagerService();
		//根据用户ID获取宝宝ID
		String babyid = usermanager.getMark(userid).getBabyid();
		if (usermanager.setParentsWatchTime(relationselect, parentname, phonenunm, starttime,endtime,idCard, userid)) {
			usermanager.updateBabyInfo(childname, selectsex, demo, selectclass, babyid);
			dataMap.put("result", "success");
			dataMap.put("message", "修改成功");
			/**
			 * 异步处理
			 */
			/*Thread thread = new Thread(new Runnable() {
				
				public void run() {
					// TODO Auto-generated method stub
					try {
						TimeUnit.SECONDS.sleep(1);
						IMmanagerUtil.updateMemberOfOldClass(phonenunm, selectclass);
						
					} catch (InterruptedException e) {
						e.printStackTrace();
					}
						
				}
				
			});
			thread.start();*/
			
			if (userpassword != null && userpassword.length() != 0) {
				// 退出群组
				String schoolroom = usermanager.getBabyInfo(babyid)
						.getSchoolroom();
				String[] schoolGroupId = schoolroom.split(",");
				String classGroupId = usermanager.getBabyInfo(babyid)
						.getClasschatroomid();
				String classname = usermanager.getBabyInfo(babyid)
						.getClassname();
				String schoolname = usermanager.getBabyInfo(babyid)
						.getSchoolname();
				try {
					result = ApiHttpClient.quitGroup(CommonUtils.rongAppKey,
							CommonUtils.rongAppSecret, oldUserName,
							classGroupId, FormatType.json);

					result = ApiHttpClient.joinGroup(CommonUtils.rongAppKey,
							CommonUtils.rongAppSecret, phonenunm, classGroupId,
							classname, FormatType.json);

					for (int m = 0; m < schoolGroupId.length; m++) {

						result = ApiHttpClient.quitGroup(
								CommonUtils.rongAppKey,
								CommonUtils.rongAppSecret, oldUserName,
								schoolGroupId[m], FormatType.json);

						result = ApiHttpClient.joinGroup(
								CommonUtils.rongAppKey,
								CommonUtils.rongAppSecret, phonenunm,
								schoolGroupId[m], schoolname, FormatType.json);
					}
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		} else {
			dataMap.put("result", "faild");
			dataMap.put("message", "修改失败");
		}
		return SUCCESS;
	}

	/**
	 * 根据下拉列表获取教师信息
	 * 
	 * @return
	 */
	public String getTeacherBySelect() {
		dataMap = new HashMap<String, Object>();
		String account = this.request.getParameter("account");
		String typeid = this.request.getParameter("typeid");
		String type = this.request.getParameter("type");
		String pageindex = request.getParameter("pageindex");
		String pagesize = request.getParameter("pagesize");
		String time = "";
//		String other = "0";
		String other = this.request.getParameter("other");
		if (pageindex == null || pageindex.length() == 0) {
			dataMap.put("result", "faild");
			dataMap.put("message", "请输入页码");
		}
		if (pagesize == null || pagesize.length() == 0) {
			dataMap.put("result", "faild");
			dataMap.put("message", "请输入每页显示数量");
		}
		if (account == null || account.length() == 0) {

			account = "";
		}
		UserManagerServiceImpl usermanager = new UserManagerService();
		dataMap.put("result", "success");
		ArrayList<user_entity> teacherlist = null;
		ArrayList<user_entity> copylist = new ArrayList<user_entity>();
		int counts = 0;
		int pagequeryIndex = Integer.parseInt(pageindex)
				* Integer.parseInt(pagesize);
		int queryPageSize = Integer.parseInt(pagesize);

		if (type.equals("1")) {

			teacherlist = usermanager.getUserListByProvinceid(pagequeryIndex,
					queryPageSize, typeid, CommonUtils.teacher, account, other,
					time);
			counts = usermanager.getTeacherCountByProvince(typeid,
					CommonUtils.teacher, account, other, time);

		} else if (type.equals("2")) {

			teacherlist = usermanager.getUserListByCityid(pagequeryIndex,
					queryPageSize, typeid, CommonUtils.teacher, account, other,
					time);
			counts = usermanager.getTeacherCountByCity(typeid,
					CommonUtils.teacher, account, other, time);

		} else if (type.equals("3")) {

			teacherlist = usermanager.getUserListByAreaid(pagequeryIndex,
					queryPageSize, typeid, CommonUtils.teacher, account, other,
					time);
			counts = usermanager.getTeacherCountByArea(typeid,
					CommonUtils.teacher, account, other, time);
		} else {

		}

		int allpagesize = (int) Math.ceil((double) counts
				/ (double) queryPageSize);
		dataMap.put("result", "success");
		dataMap.put("message", teacherlist);
		dataMap.put("counts", counts);
		dataMap.put("allpagesize", allpagesize);

		for (user_entity ue : teacherlist) {
			String userid = ue.getUserid();
			String sql1 = "select * from table_babycomment where teacherid='"
					+ userid + "'";
			String sql2 = "select * from table_trends where userid='" + userid
					+ "'";
			int commentnum;
			try {
				commentnum = link_db.getInstance().executeQuery_noobj(sql1);
				int notinum = link_db.getInstance().executeQuery_noobj(sql2);
				ue.setDianpingshu(commentnum + "");
				ue.setBangjitongzhi(notinum + "");
				copylist.add(ue);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

		}
		dataMap.put("message", copylist);
		return SUCCESS;
	}

	/**
	 * 根据下拉列表获取家长列表
	 * 
	 * @return
	 */
	public String getParentsBySelect() {
		dataMap = new HashMap<String, Object>();
		String typeid = this.request.getParameter("typeid");
		String type = this.request.getParameter("type");
		String classid = this.request.getParameter("classid");
		String account = this.request.getParameter("account");
		String schoolid = (String) request.getSession()
				.getAttribute("schoolid");
		String pageindex = request.getParameter("pageindex");
		String pagesize = request.getParameter("pagesize");
		String userType = (String) request.getSession()
				.getAttribute("usertype");
		String other = request.getParameter("other");
		String time = request.getParameter("time");
		if (pageindex == null || pageindex.length() == 0) {

			dataMap.put("result", "faild");
			dataMap.put("message", "请输入页码");
		}
		if (pagesize == null || pagesize.length() == 0) {

			dataMap.put("result", "faild");
			dataMap.put("message", "请输入每页显示数量");
		}

		if (account == null || account.length() == 0) {
			account = "";
		}

		UserManagerServiceImpl usermanager = new UserManagerService();

		dataMap.put("result", "success");
		ArrayList<user_entity> parentslist = null;
		int pagequeryIndex = Integer.parseInt(pageindex)
				* Integer.parseInt(pagesize);
		int queryPageSize = Integer.parseInt(pagesize);
		int counts = 0;
		int allpagesize;
		if (userType.equals(CommonUtils.userTypeForAdmin)
				|| userType.equals(CommonUtils.business)) {

			if (type.equals(CommonUtils.str_province)) {
				parentslist = usermanager.getUserListByProvinceid(
						pagequeryIndex, queryPageSize, typeid,
						CommonUtils.parent, account, other, time);
				counts = usermanager.getTeacherCountByProvince(typeid,
						CommonUtils.parent, account, other, time);
				

			} else if (type.equals(CommonUtils.str_city)) {
				parentslist = usermanager.getUserListByCityid(pagequeryIndex,
						queryPageSize, typeid, CommonUtils.parent, account,
						other, time);
				counts = usermanager.getTeacherCountByCity(typeid,
						CommonUtils.parent, account, other, time);

			} else if (type.equals(CommonUtils.str_area)) {
				parentslist = usermanager.getUserListByAreaid(pagequeryIndex,
						queryPageSize, typeid, CommonUtils.parent, account,
						other, time);
				counts = usermanager.getTeacherCountByArea(typeid,
						CommonUtils.parent, account, other, time);
			} else if (type.equals(CommonUtils.str_school)) {
				parentslist = usermanager.getUserListBySchoolid(pagequeryIndex,
						queryPageSize, typeid, CommonUtils.parent, account,
						other, time);
				counts = usermanager.getTeacherCount(typeid,
						CommonUtils.parent, account, other, time);
			} else {
				parentslist = usermanager.getUserListByClass(pagequeryIndex,
						queryPageSize, typeid, CommonUtils.parent, account,
						other, time);
				counts = usermanager.getPaeretCountByClassid(typeid,
						CommonUtils.parent, account, other, time);

			}

		} else {

			parentslist = usermanager.getUserListByClassid(pagequeryIndex,
					queryPageSize, classid, "0", account, schoolid,
					CommonUtils.userTypeForParkAdmin, CommonUtils.all);

			counts = usermanager
					.getPaeretCount(classid, "0", account, schoolid,
							CommonUtils.userTypeForParkAdmin, CommonUtils.all);

		}
		dataMap.put("message", parentslist);
		allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize);
		dataMap.put("result", "success");
		dataMap.put("counts", counts);
		dataMap.put("allpagesize", allpagesize);
		return SUCCESS;
	}

	/**
	 * 根据USERID 获取宝宝信息
	 */
	public String getBabyInformation() {
		this.dataMap = new HashMap<String, Object>();
		String userid = request.getParameter("userid");
		if (userid == null || userid.length() == 0) {
			dataMap.put("result", "faild");
			dataMap.put("msg", "请输入userid");
		} else {
			UserManagerServiceImpl umanager = new UserManagerService();
			dataMap.put("result", "success");
			dataMap.put("msg", umanager.getBabyInformationById(userid));
		}
		return SUCCESS;

	}

	/**
	 * 批量设置视频时间
	 */
	public String updateSetupTime() {

		dataMap = new HashMap<String, Object>();
		String userid = request.getParameter("userid");
		String endtime = request.getParameter("endtime");
		UserManagerServiceImpl userManager = new UserManagerService();
		if (userManager.setParentsWatchTime(endtime, userid)) {

			dataMap.put("result", "success");
			dataMap.put("message", "修改成功");
		} else {
			dataMap.put("result", "faild");
			dataMap.put("message", "修改失败");
		}
		return SUCCESS;
	}

	/**
	 * 根据账户状态获取家长信息
	 */
	public String getUserByOther() {

		dataMap = new HashMap<String, Object>();
		String other = request.getParameter("other");
		String condition = request.getParameter("condition");
		String time = request.getParameter("time");
		String pageindex = request.getParameter("pageindex");
		String pagesize = request.getParameter("pagesize");
		if (pageindex == null || pageindex.length() == 0) {

			dataMap.put("result", "faild");
			dataMap.put("message", "请输入页码");
		}
		if (pagesize == null || pagesize.length() == 0) {

			dataMap.put("result", "faild");
			dataMap.put("message", "请输入每页显示数量");
		}
		UserManagerServiceImpl usermanager = new UserManagerService();

		dataMap.put("result", "success");
		ArrayList<user_entity> parentslist = null;
		int pagequeryIndex = Integer.parseInt(pageindex)
				* Integer.parseInt(pagesize);
		int queryPageSize = Integer.parseInt(pagesize);
		int counts = 0;
		int allpagesize;

		parentslist = usermanager.getUserByOther(pagequeryIndex, queryPageSize,
				other, CommonUtils.parent, time, condition);
		counts = usermanager.getUserByOtherCount(other, CommonUtils.parent,
				time, condition);

		dataMap.put("message", parentslist);
		allpagesize = (int) Math.ceil((double) counts / (double) queryPageSize);
		dataMap.put("result", "success");
		dataMap.put("counts", counts);
		dataMap.put("allpagesize", allpagesize);
		return SUCCESS;
	}
	  /***
     * 以省为条件查询所有附属市的信息 yhz 
     * 
     * @return
     */
    public String getCityListByProvince() {
        String usertype = this.request.getParameter("usertype");
        String areaid = this.request.getParameter("areaid");
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        dataMap = new HashMap<String, Object>();
        UserManagerServiceImpl umanager = new UserManagerService();
        List<manager_entity> l = umanager.getCityListByProvince(usertype, areaid);
        List<manager_entity> rl = new ArrayList<>();
        int pn = Integer.parseInt(pageNum);
        int ps = Integer.parseInt(pageSize);
        if (pn > 0) {
            dataMap.put("haspre", true);
        } else {
            dataMap.put("haspre", false);
        }
        if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) {
            dataMap.put("hasnext", true);
        } else {
            dataMap.put("hasnext", false);
        }
        if (l.size() >= (pn + 1) * ps) {
            rl = l.subList(pn * ps, (pn + 1) * ps);
        } else {
            rl = l.subList(pn * ps, l.size());
        }
        dataMap.put("total", l.size());
        dataMap.put("result", "success");
        dataMap.put("message", rl);
        return SUCCESS;
    }

    /***
     * 以省为条件查询所有附属县的信息 yhz
     * 
     * @return
     */
    public String getTownDetailsByProvince() {
        String usertype = this.request.getParameter("usertype");
        String areaid = this.request.getParameter("areaid");
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        dataMap = new HashMap<String, Object>();
        UserManagerServiceImpl umanager = new UserManagerService();
        List<manager_entity> l = umanager.getTownDetailsByProvince(usertype, areaid);
        List<manager_entity> rl = new ArrayList<>();
        int pn = Integer.parseInt(pageNum);
        int ps = Integer.parseInt(pageSize);
        if (pn > 0) {
            dataMap.put("haspre", true);
        } else {
            dataMap.put("haspre", false);
        }
        if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) {
            dataMap.put("hasnext", true);
        } else {
            dataMap.put("hasnext", false);
        }
        if (l.size() >= (pn + 1) * ps) {
            rl = l.subList(pn * ps, (pn + 1) * ps);
        } else {
            rl = l.subList(pn * ps, l.size());
        }
        dataMap.put("total", l.size());
        dataMap.put("result", "success");
        dataMap.put("message", rl);
        return SUCCESS;
    }

    /***
     * 以市为条件查询所有附属县的信息 yhz
     * 
     * @return
     */
    public String getTownDetailsByCity() {
        String usertype = this.request.getParameter("usertype");
        String areaid = this.request.getParameter("areaid");
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        dataMap = new HashMap<String, Object>();
        UserManagerServiceImpl umanager = new UserManagerService();
        List<manager_entity> l = umanager.getTownDetailsByCity(usertype, areaid);
        List<manager_entity> rl = new ArrayList<>();
        int pn = Integer.parseInt(pageNum);
        int ps = Integer.parseInt(pageSize);
        if (pn > 0) {
            dataMap.put("haspre", true);
        } else {
            dataMap.put("haspre", false);
        }
        if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) {
            dataMap.put("hasnext", true);
        } else {
            dataMap.put("hasnext", false);
        }
        if (l.size() >= (pn + 1) * ps) {
            rl = l.subList(pn * ps, (pn + 1) * ps);
        } else {
            rl = l.subList(pn * ps, l.size());
        }
        dataMap.put("total", l.size());
        dataMap.put("result", "success");
        dataMap.put("message", rl);
        return SUCCESS;
    }

    /***
     * 直接查询具体县的信息 yhz
     * 
     * @return
     */
    public String getTownDetails() {
        String usertype = this.request.getParameter("usertype");
        String areaid = this.request.getParameter("areaid");
        String pageNum = request.getParameter("pageNum");
        String pageSize = request.getParameter("pageSize");
        dataMap = new HashMap<String, Object>();
        UserManagerServiceImpl umanager = new UserManagerService();
        List<manager_entity> l = umanager.getTownDetails(usertype, areaid);
        List<manager_entity> rl = new ArrayList<>();
        int pn = Integer.parseInt(pageNum);
        int ps = Integer.parseInt(pageSize);
        if (pn > 0) {
            dataMap.put("haspre", true);
        } else {
            dataMap.put("haspre", false);
        }
        if ((pn + 1) > (l.size() % ps == 0 ? l.size() / ps : (l.size() / ps + 1))) {
            dataMap.put("hasnext", true);
        } else {
            dataMap.put("hasnext", false);
        }
        if (l.size() >= (pn + 1) * ps) {
            rl = l.subList(pn * ps, (pn + 1) * ps);
        } else {
            rl = l.subList(pn * ps, l.size());
        }
        dataMap.put("total", l.size());
        dataMap.put("result", "success");
        dataMap.put("message", rl);
        return SUCCESS;
    }
	/**
	 * 根据学校ID获取教师列表
	 */
    
    /**
     * 加载菜单信息
     * 
     * @create 2015年1月16日 上午9:10:19
     */
    public String menusInfo(){
    	dataMap = new HashMap<String, Object>();
        manager_entity currUser = (manager_entity) getRequest().getSession().getAttribute("curuser");
        if(currUser == null){
            return "error"; //错误页面
        }
        
        //超级管理员特殊处理
        String super_user = BaseConf.get().getString(BaseConf._ADMINX_SECURITY_SUPER_USER);
        if(StringUtils.isBlank(StringUtils.trim(super_user))){
            super_user = "admin"; //此处需要注意.
        }
        List<Map<String,Object>> menusV = new ArrayList<Map<String,Object>>();
        List<MenuInfo> menuList = null;
        //超级管理加载所有菜单 否则加载用户拥有的菜单
        if(super_user.equals(currUser.getUsername())){
        	menuList = menuInfoService .selectAllMenus();            
            //cm = new CommonMessage(true, menuList);     
        }else{
        	UserManagerServiceImpl umanager = new UserManagerService();
        	Set<String> menuIdSet = umanager.getUserMenuIds(currUser.getRoleIds());
        	//加载菜单信息列表
        	menuList = umanager.roLoadUserMenus(menuIdSet);
        }
        Map<String,Object> menu = null;
        for (MenuInfo menuInfo : menuList) {
        	menu = new HashMap<String, Object>();
        	menu.put("id", menuInfo.getId());
        	menu.put("pid", menuInfo.getPid());
        	menu.put("name", menuInfo.getName());
        	menu.put("urlAddr", menuInfo.getUrlAddr());
        	menu.put("menuOrder", menuInfo.getMenuOrder());
        	menu.put("disFlag", menuInfo.getDisFlag());
        	menu.put("menuImgPath", menuInfo.getMenuImgPath());
        	menusV.add(menu);
		}
        List<Map<String, Object>> menus = new TreeUtil(menusV,"id","pid").getTree();
        /* cm = new CommonMessage(true, result);
//        }
        String rsMsg = gson.toJson(cm);
        printAjaxMessage(rsMsg);*/
        dataMap.put("menus", menus);
        return SUCCESS;
    }    
    
    /**
	 * @return the menuInfoService
	 */
	public MenuInfoService getMenuInfoService() {
		return menuInfoService;
	}

	/**
	 * @param menuInfoService the menuInfoService to set
	 */
	public void setMenuInfoService(MenuInfoService menuInfoService) {
		this.menuInfoService = menuInfoService;
	}
}


2. TreeUtil.java
package com.lecheng.utils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;

import com.lecheng.entity.menu.MenuInfo;
import com.lecheng.utils.demo.SimpleNode;

/**
 * 树工具类
 * @author lengzl
 * @email 819681951@qq.com
 * @create 2017年2月22日 下午2:02:06
 */
public class TreeUtil {

	private List<Map<String, Object>> list;
	private String id;
	private String parentId;

	public TreeUtil(List<Map<String, Object>> list, String id, String parentId) {
		this.list = list;
		this.id = id;
		this.parentId = parentId;
	}
	
	/**
	 * 构建树形集合
	 * @return
	 */
	public List<Map<String, Object>> getTree(){
		List<Map<String, Object>> result = new ArrayList<>(); 
		for (Map<String, Object> tmp : list) {
			if (!hasParent(tmp)) {
				setChildren(tmp);
				result.add(tmp);
			}
		}
		return result;
	}
	
	/**
	 * map是否有父节点
	 * <p>
	 * list是与map同对象类型的集合
	 * </p>
	 * @param map 目标map
	 * @param list 遍历的list
	 * @param id map的id
	 * @param parentid map的父id
	 * @return
	 */
	public boolean hasParent(Map<String, Object> map) {
		boolean flag = false;
		String key = MapUtils.getString(map, parentId);
		if (StringUtils.isNotBlank(key)) {
			for (Map<String, Object> tmp : list) {
				if (key.equals(MapUtils.getString(tmp, id))) {
					flag = true;
					break;
				}
			}
		}
		return flag;
	}
	
	/**
	 * map是否有子节点
	 * <p>
	 * list是与map同对象类型的集合
	 * </p>
	 * @param map 目标map
	 * @param list 遍历的list
	 * @param id map的id
	 * @param parentid map的父id
	 * @return
	 */
	public boolean hasChild(Map<String, Object> map) {
		boolean flag = false;
		String key = MapUtils.getString(map, id);
		if (StringUtils.isNotBlank(key)) {
			for (Map<String, Object> tmp : list) {
				if (key.equals(MapUtils.getString(tmp, parentId))) {
					flag = true;
					break;
				}
			}
		}
		return flag;
	}
	
	/**
	 * 设置子节点
	 * <p>
	 * list是与map同对象类型的集合
	 * </p>
	 * @param map 目标map
	 * @param list 遍历的list
	 * @param id map的id
	 * @param parentid map的父id
	 */
	private void setChildren(Map<String, Object> map) {
		String key = MapUtils.getString(map, id);
		if (StringUtils.isNotBlank(key)) {
			for (Map<String, Object> tmp : list) {
				if (key.equals(MapUtils.getString(tmp, parentId))) {
					if (hasChild(tmp)) {
						setChildren(tmp);
					}
					List<Map<String, Object>> children = null;
					if (map.get("children") == null) {
						children = new ArrayList<>();
					} else {
						children = (List<Map<String,Object>>) map.get("children");
					}
					children.add(tmp);
					map.put("children", children);
				}
			}
		}
	}
}



3.left.jsp
<%@page import="com.lecheng.utils.CommonUtils"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/commonYouyou.jsp"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String usertype=(String)session.getAttribute("usertype");
%>
<c:set value="${pageContext.request.contextPath }" var="path"></c:set>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>有易通幼教综合管理平台</title>
<!-- /jinanyouer/WebRoot/adminpages/js/json2.js -->
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${pageContext.request.contextPath}/adminpages/js/common/jquery/jquery-1.7.2.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/adminpages/js/adminx/json2.js"></script>
<script type="text/javascript">
$(function(){
	var userid = '${sessionScope.id}';
	var path = '${path}';
	$.post(path + '/adminLoginGetMenu.action', {
		userid : userid
	}, function(data){
		
	if (data && data.menus) {
		if (data.menus.length > 0) {
			var html = '';
			//一级菜单遍历
			$(data.menus).each(function(){
				html += '<dd><div class="title">'
					+ '<span><img src="images/leftico02.png" /></span>' + this.name
					+ '</div>'
					+ '<ul class="menuson">';
				//二级菜单遍历
				if (this.children && this.children.length > 0) {
					$(this.children).each(function(){
						//1.如果没有子节点,加path myL★)
						var sm = this.children;
						if(typeof(sm) == 'undefined'){
							html += '<li><cite></cite><a href="' + path + this.urlAddr + '" target="rightFrame">' + this.name + '</a><i></i></li>'
							return;
						//2.如果有子节点,不加path
						}else{
							html += '<li><cite></cite><a class="sa" href="javascript:;" target="rightFrame">' + this.name + '</a><i></i>'
							if(sm && sm.length > 0){
								html += '<ul style="margin-left: 50px;">';
								$(sm).each(function(){
									html += '<li><a href="'+path+this.urlAddr+'" target="rightFrame" style="color: #000000;">'+this.name+'</a></li>';
								});
								html += '</ul></li>'
							}
							
						}
						
						
					});
				}
				html += '</ul></dd>';
			});
			$('.leftmenu').append(html);
		} 
	} else {
		alert('加载菜单失败');
	}

	//原升哥的. C.v
	/* $.post(path + '/Action_getMenus.action', {
			userid : userid
	}, function(data){
		if (data && data.menus) {
			if (data.menus.length > 0) {
				var html = '';
				$(data.menus).each(function(){
					html += '<dd><div class="title">'
						+ '<span><img src="images/leftico02.png" /></span>' + this.actionname
						+ '</div>'
						+ '<ul class="menuson">';
					if (this.children && this.children.length > 0) {
						$(this.children).each(function(){
							html += '<li><cite></cite><a href="' + path + this.actionurl + '" target="rightFrame">' + this.actionname + '</a><i></i></li>';
						});
					}
					html += '</ul></dd>';
				});
				$('.leftmenu').append(html);
			}
		} else {
			alert('加载菜单失败');
		} */
	
		
		
		init();
	}); // function end
	
}); //$(function(){ end
function init(){
	//导航切换
	$(".menuson li").click(function(){
		$(".menuson li.active").removeClass("active");
		$(this).addClass("active");
	});
	
	$(".title").click(function(){
		var $ul = $(this).next("ul");
		$("dd").find("ul").slideUp();
		if($ul.is(":visible")){
			$(this).next("ul").slideUp();
		}else{
			$(this).next("ul").slideDown();
		}
	});
	$(".sa").click(function(){
		var thisa = $(this).parent();
		thisa.children("ul").slideToggle();
	});
}
</script>
</head>

<body style="background:#f0f9fd;">
	<div class="lefttop"><span></span>功能菜单</div>
    
    <dl class="leftmenu">
    	
    </dl>
    
</body>
</html>

  • 大小: 137.2 KB
  • 大小: 138.8 KB
  • 大小: 124.5 KB
分享到:
评论

相关推荐

    三叉树多叉树遍历

    三叉树多叉树遍历 c# 2.0

    树的层次遍历

    假设树用静态二叉链表存储,对树进行层次遍历。

    三级菜单树

    在IT领域,三级菜单树是一种常见的用户界面设计模式,尤其在网页和应用程序中广泛使用。它主要用于组织大量的信息,提供清晰的导航结构,使用户能够高效地浏览和访问内容。以下是对三级菜单及其相关知识点的详细说明...

    树或二元树的层次遍历

    这种遍历方法与先序(根-左-右)、中序(左-根-右)、后序(左-右-根)三种遍历策略不同,层次遍历更加直观,易于理解。在实际操作中,通常使用队列来辅助实现层次遍历,因为队列具有先进先出(FIFO)的特性,非常...

    树的遍历及其显示节点信息

    要显示树节点的基本信息,CTreeCtrl提供了如GetItemText()和SetItemText()这样的函数,可以获取或设置节点的文本信息。此外,可以利用GetItemData()和SetItemData()来存储和检索附加的数据,这些数据可以是节点数量...

    遍历json显示树形菜单

    "遍历json显示树形菜单"是一个常见的需求,涉及到的主要知识点包括JSON解析、递归遍历以及DOM操作。下面将详细阐述这些关键概念。 1. **JSON解析**: JSON是一种轻量级的数据交换格式,易于人阅读和编写,同时也...

    c#用递归方法菜单遍历

    递归是一种强大的编程技术,适用于处理具有层次结构的数据,如树形结构的菜单。本篇文章将深入探讨如何使用递归方法遍历C#中的菜单。 首先,我们需要了解菜单在C#中的表示方式。在Windows Forms应用中,菜单通常由...

    二叉排序树_层次遍历

    二叉排序树_层次遍历 二叉排序树(Binary Sort Tree,BST)是一种特殊的二叉查找树(Binary Search Tree,BST),它的每个节点都包含一个关键字,且所有左子树中的关键字都小于当前节点的关键字,所有右子树中的...

    树的前序遍历

    树的遍历是理解和操作树的关键技术之一,其中前序遍历是最基础且常用的方法。本文将深入探讨树的前序遍历算法,并结合JAVA脚本和SQL这两种不同的编程语言进行说明。 首先,我们要理解什么是树的前序遍历。前序遍历...

    实现哈夫曼树的后序遍历

    ### 实现哈夫曼树的后序遍历 在数据结构的学习过程中,哈夫曼树是一种非常重要的非线性数据结构。它广泛应用于文件压缩、编码等领域。本篇文章将详细介绍如何构建一个哈夫曼树,并实现其后序遍历算法。 #### ...

    二叉排序树-中序遍历

    采用llink-rlink方式存储二叉排序树,编写能够通过键盘输入建立二叉排序树,并在建立完立即在屏幕显示中序遍历结果的程序

    java树的前中后序遍历

    用递归和堆栈两种方法对树分别进行前中后序的遍历

    哈夫曼树创建与先序遍历.cpp

    数据结构,哈夫曼树的创建与先序遍历

    JS无限级树形菜单

    JS无限级树形菜单3种

    unity 数据结构树的深度遍历

    结合unity数据结构树的深度遍历。可以参考https://www.bilibili.com/video/av36337427?t=280 学习

    树的遍历和前序遍历后续遍历

    关于树的 遍历的小程序 和树的前序 终须遍历 和后续遍历 输入数字自动生成二叉树等功能的小程序设计

    判断二叉搜索树的前序遍历

    《剑指offer》面试题24的相关题目。输入一个整数数组,判断该数组是不是某二叉搜索树的前序遍历。假设输入的数组的任意两个数字互不相同。

Global site tag (gtag.js) - Google Analytics