前言
在自定义 mapper 时,查询多条数据可以通过 List<T> 来接收多条数据,但是上述方法没有分页。我们现在更多使用的是分页查询,所以就需要新的方法了。
实现方法
@Select("select * from comment")
IPage<CommentListVO> getAllComments(Page<?> page);
在方法参数中添加 Page<?> page 可以使返回值自动封装为 Ipage 对象。
当然它也适合多参数:
@Select("select * from comment where w_cate = #{param1} and w_id = #{param2}")
IPage<CommentListVO> getAllComments(Integer wCate, Integer wId, Page<?> page);
本文介绍如何在MyBatis Plus中实现分页查询功能。通过在Mapper接口的方法参数中添加Page对象,可以轻松地将查询结果封装为IPage对象,支持多参数查询。
7132

被折叠的 条评论
为什么被折叠?



