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);
}