查询列表信息转换

DlwyComplaints complaints = new DlwyComplaints();
complaints.setAppid(appid);
complaints.setOpenid(openid);
List complaintsList = complaintsServiceClient.getAll(complaints);
if (null != complaintsList && complaintsList.size() > 0){
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    JSONArray ja = new JSONArray();
    JSONObject jo = new JSONObject();
    for (DlwyComplaints co: complaintsList) {
        jo.put("id",co.getId());
        jo.put("title",co.getTitle());
        jo.put("content",co.getContent());
        jo.put("compTime",sdf.format(co.getCompTime()));
        ja.add(jo);
    }
    /*String result = JSONArray.fromObject(complaintsList).toString();*/
    return R.ok(ja.toString());
}else {
    return R.error("未查到信息");
}

你可能感兴趣的:(controller)