人生格言
未来犹存,人生当前
在配置类中添加一下插件
package com.gsx.config;
import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
@MapperScan("com.gsx.mapper")
public class Myconfig {
@Bean
public PaginationInterceptor paginationInterceptor(){
return new PaginationInterceptor();
}
}
测试代码
@Test
public void test(){
Page<User> page =new Page<>(1,3);
userMapper.selectPage(page,null);
System.out.println("===============================");
System.out.println(page.getCurrent());
System.out.println("===============================");
System.out.println(page.getPages());
System.out.println("===============================");
System.out.println(page.getSize());
System.out.println("===============================");
System.out.println(page.getTotal());
System.out.println("===============================");
System.out.println(page.getRecords());
System.out.println("===============================");
System.out.println(page.hasNext());
System.out.println("===============================");
System.out.println(page.hasPrevious());
}
|