Skip to content

Commit

Permalink
fix: 修复指定firstPageIndex时使用rePaging错误
Browse files Browse the repository at this point in the history
  • Loading branch information
zhou-hao committed Jul 28, 2023
1 parent a46f34d commit e66e38e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public <Q extends QueryParam> Q rePaging(int total) {
// 当前页没有数据后跳转到最后一页
if (pageIndex != 0 && (pageIndex * pageSize) >= total) {
int tmp = total / this.getPageSize();
pageIndex = total % this.getPageSize() == 0 ? tmp - 1 : tmp;
pageIndex = (total % this.getPageSize() == 0 ? tmp - 1 : tmp) + firstPageIndex;
}
return (Q) this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ public void testCustomFirstPage(){

Assert.assertEquals(param.getThinkPageIndex(),2);

param.rePaging(0);

Assert.assertEquals(param.getPageIndex(),0);

Assert.assertEquals(param.getThinkPageIndex(),1);

param.setPageIndex(2);
param.rePaging(12);

Assert.assertEquals(param.getPageIndex(),1);

Assert.assertEquals(param.getThinkPageIndex(),2);
}

@Test
Expand Down

0 comments on commit e66e38e

Please sign in to comment.