1.配置分页插件
@Configuration
@MapperScan("com.example.mapper.*")
public class MybatisPlusConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
return paginationInterceptor;
}
}
2.Mapper直接调用分页
IPage<TOperlog> operlogIPage = new Page<>(pageNum, pageSize);
operlogIPage = tOperlogMapper.selectPage(operlogIPage,null);
3.Service调用分页
sevice里面
Page<TRolePermissionsVo> page = new Page<>(pageNum,pageSize);
IPage iPage = rolePermissionsMapper.getRolePermission(page,roleId);
mapper里面
IPage<TRolePermissionsVo> getRolePermission(Page<TRolePermissionsVo> page, @Param("roleId") Integer roleId);