码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-03-15 14:27:21      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:base   需求   sql   name   erro   cat   return   success   ror   

 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 ---- 分页查询,,源码

标签:base   需求   sql   name   erro   cat   return   success   ror   

原文地址:https://www.cnblogs.com/Darkqueen/p/10536641.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!