提交 87c0f73e 编写于 作者: P peng-yongsheng

Make the page number to be 1 when the value equal to 0.

上级 de81e211
......@@ -28,7 +28,7 @@ public enum PaginationUtils {
public Page exchange(Pagination paging) {
int limit = paging.getPageSize();
int from = paging.getPageSize() * (paging.getPageNum() - 1);
int from = paging.getPageSize() * ((paging.getPageNum() == 0 ? 1 : paging.getPageNum()) - 1);
return new Page(from, limit);
}
......
......@@ -37,6 +37,13 @@ public class PaginationUtilsTestCase {
Assert.assertEquals(0, page.getFrom());
Assert.assertEquals(10, page.getLimit());
pagination = new Pagination();
pagination.setPageSize(10);
page = PaginationUtils.INSTANCE.exchange(pagination);
Assert.assertEquals(0, page.getFrom());
Assert.assertEquals(10, page.getLimit());
pagination = new Pagination();
pagination.setPageSize(10);
pagination.setPageNum(2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册