MybatisPlus分页查询

1年前 (2022) 程序员胖胖胖虎阿
145 0 0

👏👏👏

哈喽!大家好,我是【学无止境小奇】,一位热爱分享各种技术的博主!😍😍😍

⭐【学无止境小奇】的创作宗旨:每一条命令都亲自执行过,每一行代码都实际运行过,每一种方法都真实实践过,每一篇文章都良心制作过。✊✊✊

⭐【学无止境小奇】的博客中所有涉及命令、代码的地方,除了提供图片供大家参考,另外会在图片下方提供一份纯文本格式的命令或者代码方便大家粘贴复制直接执行命令或者运行代码。🤝🤝🤝

⭐如果你对技术有着浓厚的兴趣,欢迎关注【学无止境小奇】,欢迎大家和我一起交流。😘😘😘

❤️❤️❤️感谢各位朋友接下来的阅读❤️❤️❤️

文章目录

  • 一、Mybatis分页查询
    • 1、Mybatis分页查询
      • 1.1、创建返回对象类
      • 1.2、开启分页

一、Mybatis分页查询

1、Mybatis分页查询

1.1、创建返回对象类

创建一个返回对象类,用来放返回给前台的数据

MybatisPlus分页查询

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RespPageBean {

    /**
     * 总条数
     */
    private Long total;
    /**
     * 数据list
     */
    private List<?> data;
}

1.2、开启分页

打开开启分页开关

MybatisPlus分页查询

 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;
    }

版权声明:程序员胖胖胖虎阿 发表于 2022年11月8日 上午8:24。
转载请注明:MybatisPlus分页查询 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...