分页参数 page在哪里实现的呢可以举个列子吗
时间: 2023-12-09 09:03:14 浏览: 33
分页参数 `page` 是通过 MyBatis Plus 框架提供的 `IPage` 接口来实现的。在使用 MyBatis Plus 进行数据库查询时,可以将查询结果封装在 `IPage` 对象中,以实现分页功能。
以下是一个示例:
```java
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
public IPage<FollowUpPatient> findPatientList(IPage<FollowUpPatient> page, Long tenaId, List<Long> groupIdList, List<Long> labelIdList, Date startTime, Date endTime) {
// 创建查询条件
QueryWrapper<FollowUpPatient> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("tena_id", tenaId);
queryWrapper.in("group_id", groupIdList);
queryWrapper.in("label_id", labelIdList);
queryWrapper.ge("start_time", startTime);
queryWrapper.le("end_time", endTime);
// 执行查询
IPage<FollowUpPatient> resultPage = followUpPatientMapper.selectPage(page, queryWrapper);
return resultPage;
}
```
在这个示例中,`findPatientList` 方法接受一个 `IPage<FollowUpPatient>` 对象作为分页参数。使用 MyBatis Plus 提供的 `QueryWrapper` 对象来构建查询条件。然后,调用 `followUpPatientMapper.selectPage` 方法执行查询,并将分页参数 `page` 和查询条件 `queryWrapper` 作为参数传入。
最后,返回执行查询后得到的分页结果 `resultPage`。这样,你就可以通过 `resultPage` 获取特定页码的数据,并且能够进行灵活的筛选和排序操作。