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);
final JSONArray json = new JSONArray();
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
List<String> list = new LinkedList<String>();
while (rs.next()){
JSONObject jo = new JSONObject();
jo.put("user_type",rs.getString("user_type"));
jo.put("create_time", rs.getString("create_time"));
jo.put("process_code", rs.getString("process_code"));
jo.put("idtbl_cell_process_log_id", rs.getString("idtbl_cell_process_log_id"));
jo.put("powder_type", rs.getString("powder_type"));
jo.put("process_source", rs.getString("process_source"));
jo.put("cell_id", rs.getString("cell_id"));
jo.put("code", rs.getString("code"));
json.add(jo);
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 json;
}
});
dao().execute(sql);
return sql.getList(String.class);
// Nutz内置了大量回调, 请查看Sqls.callback的属性
}