标签:end service new int from public param ++ append
@ResponseBody
@RequestMapping({"treeData"})
public Map<String, Object> treeData(@RequestParam(required=false) String extId)
{
Map<String, Object> mapList = new HashMap<String, Object>();
StringBuffer sb=new StringBuffer();
sb.append("{");
List<PlmBasService> list = plmBasServiceService.getByUpServiceId("100");
for (int i = 0; i < list.size(); i++) {
PlmBasService e=list.get(i);
String childtree=childData(e.getId());
if(!childtree.equals("")) {
sb.append("\‘" + e.getId() + "\‘ : {name: \‘"
+ e.getServiceName() + "\‘,type:\‘folder\‘ ,\‘additionalParameters\‘:"+childtree+"},");
}else {
sb.append("\‘" + e.getId() + "\‘ : {name: \‘"
+ e.getServiceName() + "\‘,type:\‘folder\‘},");
}
}
sb.append("}");
JSONObject jsonObject = JSONObject.fromObject(sb.toString());
mapList.put("tree_data",jsonObject);
return mapList;
}
public String childData(String UpServiceId)
{
StringBuffer sb=new StringBuffer();
sb.append("{\‘children\‘:{");
List<PlmBasService> list = plmBasServiceService.getByUpServiceId(UpServiceId);
for (int i = 0; i < list.size(); i++) {
PlmBasService e=list.get(i);
if(!childData(e.getId()).equals("")) {
sb.append("\‘" + e.getId() + "\‘ : {name: \‘"
+ e.getServiceName() + "\‘,type:\‘folder\‘,\‘additionalParameters\‘:"+childData(e.getId())+"},");
}else {
sb.append("\‘" + e.getId() + "\‘ : {name: \‘"
+ e.getServiceName() + "\‘,type:\‘folder\‘},");
}
}
sb.append("}}");
return sb.toString();
}
标签:end service new int from public param ++ append
原文地址:https://www.cnblogs.com/StuM/p/11202713.html