一、Mybatis分页查询
1、Mybatis分页查询
1.1、创建返回对象类
创建一个返回对象类,用来放返回给前台的数据
@Data @NoArgsConstructor @AllArgsConstructor public class RespPageBean { /** * 总条数 */ private Long total; /** * 数据list */ private List<?> data; }
1.2、开启分页
打开开启分页开关
public RespPageBean getEmployeeByPage(Integer currentPage, Integer size, Employee employee, LocalDate[] beginDateScope) { //开启分页 Page<Employee> page = new Page<>(currentPage, size); IPage<Employee> employeeByPage = employeeMapper.getEmployeeByPage(page, employee, beginDateScope); RespPageBean respPageBean = new RespPageBean(employeeByPage.getTotal(),employeeByPage.getRecords()); return respPageBean; }