package com.tcl.jr.crm.util;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.tcl.jr.crm.entity.Tree;
/**
* 类名称:MenuTreeUtil
* 类描述:递归构造树型结构
*/
public class MenuTreeUtil {
public static Map mapArray = new LinkedHashMap();
public List menuCommon;
public List
3、最后在控制台请求方法调用数据就行了,在controller的方法如下:
/**
* 显示APP树形结构
*/
@RequestMapping(value = { "getAPPTree" }, produces = "text/html;charset=UTF-8")
@ResponseBody
public String getAPPTree(HttpServletRequest request, HttpServletResponse response) throws Exception {
Map returnmap = new HashMap<>();
MenuTreeUtil menuTree = new MenuTreeUtil();
PageData pd = this.getPageData();
try {
//这里的方法是根据前台的机构类型代码来查找数据库数据的,这里不多加解释,因人而异
List list = dataDicService.buildTree(pd.getString("instType"));
List menuList = menuTree.menuList(list);
//区别于web端,这边APP端list不能转为json格式,直接将list传给前台,转成json对象的话vuejs前台无法识别渲染
returnmap.put("list", menuList);
} catch (Exception e) {
logger.error(e.getMessage());
}
return JsonMapper.toJsonString(returnmap);
}