@ApiModelProperty(value = "开始页")
private Integer page = 1;
@ApiModelProperty(value = "每页数据个数")
private Integer rows = 10;
以上是前端传过来的数据
@Override
public Map<String,Object> getFbList(EleInput EleInput) {
HashMap<String, Object> stringObjectHashMap = new HashMap<>();
Integer page = EleInput.getPage();
Integer rows = EleInput.getRows();
EleInput.setPage((page - 1)*rows);
List<Ele> fbList = EleMapper.getFbList(EleInput);
int fbListCount = EleMapper.getFbListCount(EleInput);
stringObjectHashMap.put("list",fbList);
stringObjectHashMap.put("count",fbListCount);
return stringObjectHashMap;
}
xml 里面写法
@Configuration
//@MapperScan("com.example.demo.mapper")
public class MybatisPlusConfig {
/**
* 新增分页拦截器,并设置数据库类型为mysql
* @return
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}
业务层
//分页参数
Page<SchoolStudent> rowPage = new Page(page, pageSize);
//queryWrapper组装查询where条件
LambdaQueryWrapper<SchoolStudent> queryWrapper = new LambdaQueryWrapper<>();
rowPage = this.baseMapper.selectPage(rowPage, queryWrapper);
return rowPage;