public QueryResult getHistoryIncome(int d, int curPage)
throws Exception {
/**sql**/
Sql sql = Sqls.create("select a,b,c from A where d=@d ")
.setParam("d", d);
/**查询个数**/
Sql sqlcount = Sqls.create("SELECT count(*)as number FROM mytask t WHERE d = @d")
.setParam("d", d);
sqlcount.setCallback(Sqls.callback.entity());
sqlcount.setEntity(dao.getEntity(Record.class));
dao.execute(sqlcount);
Record countRecord=(Record) sqlcount.getResult();
long count=(long) countRecord.get("number");
if(curPage==0){
curPage=1;
}
Pager pager=dao.createPager(curPage, 10);
pager.setRecordCount((int) count);
sql.setPager(pager);
/**列表**/
sql.setCallback(Sqls.callback.entities());
Entity<Record> entity = dao.getEntity(Record.class);
sql.setEntity(entity);
dao.execute(sql);
return new QueryResult(sql.getList(Record.class), pager);
}
取出列表信息:
QueryResult对象.getList(Record.class);
取出分页信息
QueryResult对象.getPager();