@TOC
配置类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| import com.baomidou.mybatisplus.annotation.DbType; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;
@Configuration public class MybatisConfig { @Bean public MybatisPlusInterceptor mybatisPlusInterceptor() { MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); return interceptor; } }
JAVA
|
测试
1 2 3 4 5 6 7 8
| @GetMapping("/list") @Operation(summary = "获取用户", description = "获取用户信息,分页") public List<User> list(int current, int size) { Page<User> page = new Page<>(current, size); userService.page(page); return page.getRecords(); }
JAVA
|
即可。
上述为基础的分页查询,如有复杂的高级查询,也支持。