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();
原文地址:https://www.cnblogs.com/Darkqueen/p/10536641.html
时间: 2024-10-12 19:12:33