日期:2014-05-19 浏览次数:20646 次
@SuppressWarnings("unchecked")
public PageModel<Book> findByTypeName(int pageNo, int pageSize,
String typename) {
String sql = "select * from ("
+ " select *,row_number() over(order by pubtime) rownum "
+ " from new_book where typename = ?) temp "
+ " where rownum between ? and ?";
List<Book> all = new ArrayList<Book>();
PageModel<Book> pageModel = new PageModel<Book>();
int counts = this.getTotalRecords("select count(1) from new_book where typename = " + typename);
if(counts <=0) {
return null;
} else {
pageModel.setTotalRecords(counts);
pageModel.setTotalPages();
pageModel.setPageNo(pageNo);
int start = pageModel.getPageSize()*(pageModel.getPageNo()-1) + 1;
int end = pageModel.getPageSize()*pageModel.getPageNo();
all = getJdbcTemplate().queryForList(sql, new Object[] {typename ,start, end});
System.out.println(sql + " " + start + " " + end + " " + typename + " " + counts);
System.out.println("List 大小:" + all.size());
pageModel.setList(all);
return pageModel;
}
}