解决消息分页问题

This commit is contained in:
ajaxfan
2021-03-06 09:41:43 +08:00
parent 5d0f1a4d22
commit 46614cb8c1
2 changed files with 9 additions and 4 deletions

View File

@ -13,11 +13,17 @@ public class PageDTO {
@ApiModelProperty(required = false, value = "当前页默认1")
private int current;
@ApiModelProperty(required = false, value = "页码默认1")
private int pageNo;
@ApiModelProperty(required = false, value = "单页数量默认15")
private int pageSize;
public PageDTO() {
this.current = 1;
this.pageNo = 1;
this.pageSize = 15;
}
}

View File

@ -69,14 +69,13 @@ public class BizMessageConsumerServiceImpl implements BizMessageConsumerService
* @return
*/
private PageDTO createPageCondition(PageDTO page) {
page = Optional.ofNullable(page).map(p -> {
return Optional.ofNullable(page).map(p -> {
p.setCurrent(Math.max(1, p.getCurrent()));
p.setPageNo(Math.max(1, p.getPageNo()));
p.setPageSize(p.getPageSize() == 0 ? 15 : p.getPageSize());
return p;
}).orElseGet(PageDTO::new);
return page;
}
}