Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【功能请求】自定义 count sql 获取 PageInfo 对象请求 #788

Closed
1 task done
WangJincheng4869 opened this issue Dec 19, 2023 · 2 comments
Closed
1 task done

Comments

@WangJincheng4869
Copy link

WangJincheng4869 commented Dec 19, 2023

  • 我已在 issues 搜索类似问题,并且不存在相同的问题.

功能建议

目前在 PageInfo 存在一个 of 方法,这个方法在使用 PageHelper.startPage(0, 10) 时可以正常获取全部属性值,但是当使用 PageHelper.startPage(0, 10, false) 时会导致无法获取完整的属性值,有以下的功能请求:

  1. of 方法添加一个 total 参数,传入总数然后返回完整的属性值
long total = userMapper.selectCount();
if (total == 0) {
  return new ArrayList<User>();
}
PageHelper.startPage(0, 10, false)
List<User> list = userMapper.select();
PageInfo<User> pageInfo = PageInfo.of(list);
  1. of 方法添加一个 ISelect 参数,可以将查询方法写在函数中,然后返回完整的属性值
PageHelper.startPage(0, 10, () -> userMapper.selectCount());
List<User> list = userMapper.select();
PageInfo<User> pageInfo = PageInfo.of(list);

我比较喜欢第一种方式,因为正常来讲,当数据为 0 的时候,就不必继续执行查询语句了。

@abel533
Copy link
Collaborator

abel533 commented Dec 21, 2023

来个PR?

@abel533 abel533 pinned this issue Dec 21, 2023
@yesAnd92
Copy link
Contributor

yesAnd92 commented Jan 4, 2024

我也有这个场景的需求,如果没人认领,我来提个PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants