mybatis ---- 分页查询,,源码

Posted 每天性感一点点

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mybatis ---- 分页查询,,源码相关的知识,希望对你有一定的参考价值。

 PageHelper 有封装的分页插件---直接用即可

@GetMapping("/toDeptList")
public BaseResponse toDeptList(Model model,@RequestParam(required = false,defaultValue = "1",value = "pn")Integer pn ) {
BaseResponse response = new BaseResponse();
try{
PageHelper.startPage(pn, 15); //pn--页数,定值---每页的数量
List<ReleaseBase> rbList = rbService.searchData(); //查询表里所有的数据
PageInfo<ReleaseBase> p = new PageInfo<>(rbList);
model.addAttribute("deptList", rbList);
model.addAttribute("page", p);
response.setData(rbList);
response.setSuccess(true);
return response;
}catch (Exception e){
response.setErrorMsg(ErrorCode.SYSTEM_ERROR.getDesc());
}
return response;
}

sql ://根据需求要求条件查询
@Select(" SELECT  rb.*,cp.scale  FROM release_base rb,company cp WHERE  rb.is_bid LIKE ‘%${is_bid}%‘ AND rb.live LIKE ‘%${live}%‘ AND rb.education LIKE ‘%${education}%‘ AND rb.bounty LIKE ‘%${bounty}%‘ AND rb.num LIKE ‘%${num}%‘ AND rb.type like ‘%${type}%‘ AND rb.creat_time LIKE ‘%${creat_time}%‘ AND cp.scale LIKE ‘%${scale}%‘ and rb.category_name LIKE ‘%${category_name}%‘ group  by  creat_time  ")
List<ReleaseBase> searchData();

以上是关于mybatis ---- 分页查询,,源码的主要内容,如果未能解决你的问题,请参考以下文章

基于 mybatis 的分页和过滤查询

mybatis分页查询怎么做

Mybatis-plus之分页泛型转换

mybatis-plus分页查询

MyBatisPlus 分页插件和数据库行锁的几点思考

SpringBoot + Mybatis-puls + ClickHouse (分页查询添加修改删除)