先看《分页》再看这个 分页page错误示范
错误示范
controller层
查询条件放在了java中
1 /** 2 * @param userId 用户id 3 * @param pageSize 每条页数 4 * @param pageNum 第几页 5 * @return 6 */ 7 @ApiOperation("查询点分页列表") 8 @PostMapping("/pageList") 9 @ResponseBody 10 public Response pageList(Integer userId, Integer pageSize, Integer pageNum) { 11 QueryWrapper<Point> queryWrapper = new QueryWrapper<>(); 12 queryWrapper.eq("user_id", userId); 13 PageHelper.startPage(pageNum, pageSize); 14 List<Point> list = pointMapper.selectListBYList(userId); 15 PageInfo<Point> page = new PageInfo<>(list); 16 return new Response(ResponseEnum.SUCCESS, page); 17 }
正确示范
controller层
1 /** 2 * @param userId 用户id 3 * @param pageSize 每条页数 4 * @param pageNum 第几页 5 * @return 6 */ 7 @ApiOperation("查询点分页列表") 8 @PostMapping("/pageList") 9 @ResponseBody 10 public Response pageList(Integer userId, Integer pageSize, Integer pageNum) { 11 PageHelper.startPage(pageNum, pageSize); 12 List<Point> list = pointMapper.selectListBYList(userId); 13 PageInfo<Point> page = new PageInfo<>(list); 14 return new Response(ResponseEnum.SUCCESS, page); 15 }
mapper.xml层
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 <mapper namespace="com.chengdu.water.mapper.PointMapper"> 4 5 <select id="selectListBYList" resultType="com.chengdu.water.entity.Point"> 6 select * from point where user_id = #{userId} 7 </select> 8 </mapper>
每天多努力一点,你将会变得更好。