Mybatis-Plus的IPage和Page

Mybatis-Plus 中的分页查询接口主要有两个:IPage 和 Page。

IPage 接口:
IPage 是 Mybatis-Plus 中的分页结果集接口,它继承了 Mybatis 的 RowBounds 接口,提供了一系列的分页查询方法。该接口主要用于返回分页后的数据结果。

Page 类:
Page 类是 IPage 接口的默认实现类,实现了 IPage 接口中的方法。在进行分页查询时,通常会创建一个 Page 对象,并设置相关的分页参数。

以下是 IPage 和 Page 类的常用参数:

current:当前页数,必须大于等于 1,默认值为 1。
size:每页条数,默认值为 10。
total:总条数,默认值为 0。
records:当前页数据集合,默认值为空集合。
searchCount:是否进行 count 查询,默认值为 true,表示会统计总条数。
pages:总页数,通过计算得出。
optimizeCountSql:是否优化 count 查询,默认值为 true。
hitCount:是否对 count 进行 limit 优化,默认值为 false。
countId:count 查询的列名,默认为 null,表示所有列。
maxLimit:设置最大的 limit 查询限制,默认值为 -1,表示不限制。

 IPage<CustomerVO> page=new Page<>(customerDTO.getPageNum(),customerDTO.getPageSize());
        IPage<CustomerVO> sysUserList=  userMapper. selectCustomerList(page,customerDTO);
    IPage<CustomerVO> selectCustomerList(@Param("page")IPage<CustomerVO> page ,@Param("customerDTO") CustomerDTO customerDTO);

 别忘了开启分页

/**
 * 启动程序
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.cgwenjian", "com.cgwenjian"})
@EnableAsync
public class Application {
    public static void main(String[] args) {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(Application.class, args);
        System.out.println("【文兜智写启动成功】");
    }
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); // 添加分页插件
        return interceptor;
    }
}

  • 6
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值