public List demoSql(Integer cellId,Integer pageNum) {
Sql sql = Sqls.create("SELECT a.*,b.code FROM tbl_cell_process_log
as a, tbl_cell as b where a.cell_id=@id and a.cell_id=b.idtbl_cell ORDER BY a.create_time desc");
sql.params().set("id", cellId);
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<String> list = new LinkedList<String>();
while (rs.next()){
list.add(rs.getString("user_type"));
list.add(rs.getString("create_time"));
list.add(rs.getString("process_code"));
list.add(rs.getString("idtbl_cell_process_log_id"));
list.add(rs.getString("powder_type"));
list.add(rs.getString("process_source"));
list.add(rs.getString("cell_id"));
list.add(rs.getString("code"));
}
return list;
}
});
dao().execute(sql);
return sql.getList(String.class);
// Nutz内置了大量回调, 请查看Sqls.callback的属性
}
附注说明:这个返回的数据是{"obj":["0", "2017-10-30 10:31:38.0", "1", "9598", "1", "0", "2424", "1901", "0", "2017-10-27 16:35:16.0", "5", "9471", "4", "1", "2424", "1901", "0", "2017-10-27 16:33:13.0", "5", "9470", "4", "1", "2424", "1901", "0", "2017-10-27 09:06:58.0", "0", "9419", "2", "0", "2424", "1901", "0", "2017-10-27 09:06:33.0", "0", "9418", "2", "0", "2424", "1901", "0", "2017-10-27 09:06:16.0", "0", "9417", "2", "0", "2424", "1901", "0", "2017-10-27 09:01:21.0", "5", "9414", "4", "1", "2424", "1901", "0", "2017-10-27 09:00:24.0", "1", "9413", "1", "0", "2424", "1901", "0", "2017-10-27 09:00:08.0", "1", "9412", "1", "0", "2424", "1901", "0", "2017-10-27 08:59:37.0", "1", "9411", "1", "0", "2424", "1901", "0", "2017-10-27 08:58:47.0", "5", "9409", "4", "1", "2424", "1901", "0", "2017-10-27 08:46:46.0", "5", "9406", "4", "1", "2424", "1901", "2", "2017-10-23 15:58:58.0", "0", "9128", "1", "0", "2424", "1901", "0", "2017-10-23 07:44:27.0", "1", "9062", "1", "0", "2424", "1901", "2", "2017-10-22 10:15:13.0", "0", "9023", "1", "0", "2424", "1901", "0", "2017-10-14 11:14:00.0", "1", "8503", "1", "0", "2424", "1901", "0", "2017-10-12 09:35:59.0", "1", "8370", "1", "0", "2424", "1901", "0", "2017-10-12 09:35:34.0", "5", "8369", "4", "1", "2424", "1901", "0", "2017-10-11 15:10:48.0", "1", "8354", "1", "0", "2424", "1901", "0", "2017-10-11 15:10:17.0", "5", "8353", "4", "1", "2424", "1901", "2", "2017-10-10 11:03:18.0", "0", "8281", "1", "0", "2424", "1901", "0", "2017-10-10 11:01:43.0", "5", "8277", "4", "1", "2424", "1901", "0", "2017-10-10 10:24:33.0", "5", "8270", "4", "1", "2424", "1901", "0", "2017-10-10 10:24:18.0", "5", "8269", "4", "1", "2424", "1901", "0", "2017-10-10 10:24:08.0", "1", "8267", "1", "0", "2424", "1901", "0", "2017-10-10 10:23:33.0", "1", "8266", "1", "0", "2424", "1901", "0", "2017-10-10 10:22:56.0", "5", "8265", "4", "1", "2424", "1901", "0", "2017-10-08 21:16:41.0", "5", "8220", "4", "1", "2424", "1901", "0", "2017-09-28 13:57:11.0", "1", "7725", "1", "0", "2424", "1901", "0", "2017-09-26 15:37:47.0", "1", "7616", "1", "0", "2424", "1901", "0", "2017-09-07 14:17:31.0", "1", "6770", "1", "0", "2424", "1901", "0", "2017-09-07 14:17:05.0", "1", "6769", "1", "0", "2424", "1901", "0", "2017-09-07 14:17:04.0", "5", "6768", "4", "1", "2424", "1901", "0", "2017-09-07 14:15:09.0", "1", "6767", "1", "0", "2424", "1901", "0", "2017-08-05 16:15:53.0", "1", "5145", "1", "0", "2424", "1901", "0", "2017-05-03 10:37:57.0", "1", "3436", "1", "0", "2424", "1901"],"state":"1"}
想要实现返回:{"obj":{"currentPage":1,"pageSize":10,"recordList":[{"idtbl_cell_process_log_id":9598,"cell_id":2424,"process_code":1,"powder_type":1,"process_source":0,"user_type":0,"create_time":"2017-10-30 10:31:38"}, {"idtbl_cell_process_log_id":9471,"cell_id":2424,"process_code":5,"powder_type":4,"process_source":1,"user_type":0,"create_time":"2017-10-27 16:35:16"}, {"idtbl_cell_process_log_id":9470,"cell_id":2424,"process_code":5,"powder_type":4,"process_source":1,"user_type":0,"create_time":"2017-10-27 16:33:13"}, {"idtbl_cell_process_log_id":9419,"cell_id":2424,"process_code":0,"powder_type":2,"process_source":0,"user_type":0,"create_time":"2017-10-27 09:06:58"}, {"idtbl_cell_process_log_id":9418,"cell_id":2424,"process_code":0,"powder_type":2,"process_source":0,"user_type":0,"create_time":"2017-10-27 09:06:33"}, {"idtbl_cell_process_log_id":9417,"cell_id":2424,"process_code":0,"powder_type":2,"process_source":0,"user_type":0,"create_time":"2017-10-27 09:06:16"}, {"idtbl_cell_process_log_id":9414,"cell_id":2424,"process_code":5,"powder_type":4,"process_source":1,"user_type":0,"create_time":"2017-10-27 09:01:21"}, {"idtbl_cell_process_log_id":9413,"cell_id":2424,"process_code":1,"powder_type":1,"process_source":0,"user_type":0,"create_time":"2017-10-27 09:00:24"}, {"idtbl_cell_process_log_id":9412,"cell_id":2424,"process_code":1,"powder_type":1,"process_source":0,"user_type":0,"create_time":"2017-10-27 09:00:08"}, {"idtbl_cell_process_log_id":9411,"cell_id":2424,"process_code":1,"powder_type":1,"process_source":0,"user_type":0,"create_time":"2017-10-27 08:59:37"}],"recordCount":5,"pageCount":1,"beginPageIndex":1,"endPageIndex":1},"state":"1"}