高级查询,分页

高级查询,分页:

1:service层:

代码:

 1   @Override
 2     public QueryLimitPageObj queryLimitPage(ProductQueryObj productQueryObj) {
 3         QueryLimitPageObj queryLimitPageObj = new QueryLimitPageObj();
 4       //查询列表
 5         List<Product> products = productDao.chooseQuery(productQueryObj);
 6         queryLimitPageObj.setData(products);
 7         //当前页
 8         Integer currentPage = productQueryObj.getCurrentPage();
 9         queryLimitPageObj.setCurrentPage(currentPage);
10         //每页显示条数
11         Integer pageSize = productQueryObj.getPageSize();
12         queryLimitPageObj.setPageSize(pageSize);
13         //总条数
14         int totalNum = productDao.getTotalNum(productQueryObj);
15         queryLimitPageObj.setTotalNum(totalNum);
16         //总页数
17          queryLimitPageObj.setTotalPage((totalNum + pageSize - 1)/ pageSize);
18         return queryLimitPageObj;
19     }
View Code

2:封装分页对象:

3.封装高级查询对象:

猜你喜欢

转载自www.cnblogs.com/dw3306/p/9349129.html