分页IPage<QyjbxxPo> pageInfo转List。查询列表导出excel同一个入口

1、public List getAllInfo(QyjbxxVo qyjbxxVo) {
    Page page = new Page<>(1, 100000000);
    IPage pageInfo = iQyjbxxService.getPageInfo(page, qyjbxxVo);
    //转换为Dto
    List qyjbxxPos = new ArrayList<>();
    if (CollectionUtil.isEmpty(pageInfo.getRecords())) {
        return null;
    }
    for (QyjbxxPo u : pageInfo.getRecords()) {
        QyjbxxPo userVo = new QyjbxxPo(u);
        qyjbxxPos.add(userVo);
    }
    return qyjbxxPos;
}

2、导出

new ExcelUtils().exportExcelByTemplate("Qyjbxx", "企业基本信息", list, response);
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
在 Mybatis-Plus 中,我们可以通过自定义 XML 文件来实现复杂的 SQL 操作,包括分页查询。下面是一个示例,演示如何使用自定义 XML 文件实现 Mybatis-Plus 分页查询: ```xml <!-- Mybatis 自定义 XML 文件 --> <mapper namespace="com.example.mapper.UserMapper"> <select id="selectUserList" resultType="com.example.entity.User"> select * from user <where> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%') </if> </where> </select> <!-- 分页查询 --> <select id="selectUserPage" resultMap="userResultMap"> select * from user <where> <if test="name != null and name != ''"> and name like concat('%', #{name}, '%') </if> </where> <if test="page != null"> limit #{page.current}, #{page.size} </if> </select> </mapper> ``` 其中,`selectUserList` 是一个普通的查询语句,`selectUserPage` 则是一个带有分页参数的查询语句。在分页查询中,我们需要使用 `limit` 关键字来控制返回数据的数量,同时,我们也需要将分页信息传递给 SQL 语句。这里,我们通过 Mybatis 的参数处理机制来实现,在 XML 文件中使用 `${paramName}` 取出参数值。 接下来,我们需要在 Java 代码中调用该查询语句,从而实现分页查询。示例代码如下: ```java @Service public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService { @Override public IPage<User> getUserPage(Page<User> page, String name) { return baseMapper.selectUserPage(page, name); } } ``` 在 Service 实现类中,我们通过 `baseMapper` 来调用自定义 SQL 语句,其中 `selectUserPage` 方法返回一个 `IPage<User>` 对象,表示查询结果。最后,我们将该对象返回给控制器,完成分页查询

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

菜鸟是大神

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值