1 changed files with 62 additions and 0 deletions
@ -0,0 +1,62 @@ |
|||
package com.jeecg.modules.jmreport.adapter; |
|||
|
|||
import com.alibaba.fastjson.JSONArray; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import org.jeecg.modules.jmreport.desreport.render.handler.convert.ApiDataConvertAdapter; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author wangpengfei |
|||
* @date 2023/12/7 9:53 |
|||
*/ |
|||
@Component("customParser") |
|||
public class MyApiDataConvertAdapter implements ApiDataConvertAdapter { |
|||
@Override |
|||
public String getData(JSONObject jsonObject) { |
|||
System.out.println(jsonObject); |
|||
// if(jsonObject.containsKey("pagelist")){
|
|||
// JSONArray pageList = jsonObject.getJSONArray("pagelist");
|
|||
// JSONArray array = new JSONArray();
|
|||
// for (int i = 0; i < pageList.size(); i++) {
|
|||
// JSONObject object = new JSONObject();
|
|||
// String name = pageList.getJSONObject(i).getString("name");
|
|||
// String id = pageList.getJSONObject(i).getString("id");
|
|||
// String zhicheng = pageList.getJSONObject(i).getString("zhicheng");
|
|||
// JSONArray fuze = pageList.getJSONObject(i).getJSONArray("fuze");
|
|||
// for (int j = 0; j < fuze.size(); j++) {
|
|||
// String banji = fuze.getJSONObject(j).getString("banji");
|
|||
// String xueke = fuze.getJSONObject(j).getString("xueke");
|
|||
// object.put("name",name);
|
|||
// object.put("id",id);
|
|||
// object.put("zhicheng",zhicheng);
|
|||
// object.put("banji",banji);
|
|||
// object.put("xueke",xueke);
|
|||
// array.add(object);
|
|||
// }
|
|||
// }
|
|||
// return pageList.toJSONString();
|
|||
// }else{
|
|||
// return "";
|
|||
// }
|
|||
return jsonObject.getJSONArray("date").toJSONString(); |
|||
} |
|||
|
|||
@Override |
|||
public String getTotal(JSONObject jsonObject) { |
|||
|
|||
return jsonObject.containsKey("total") ? jsonObject.get("total").toString() : "0"; |
|||
} |
|||
|
|||
@Override |
|||
public String getCount(JSONObject jsonObject) { |
|||
|
|||
return jsonObject.containsKey("count") ? jsonObject.get("count").toString() : "0"; |
|||
} |
|||
|
|||
@Override |
|||
public String getLinks(JSONObject jsonObject) { |
|||
|
|||
return jsonObject.containsKey("links") ? jsonObject.get("links").toString() : ""; |
|||
} |
|||
|
|||
} |
Loading…
Reference in new issue