• 使用PageInfo分页查询列表


    先引入依赖

        <!-- pageHelper -->
    <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>1.2.13</version>
    <exclusions>
    <exclusion>
    <artifactId>mybatis-spring</artifactId>
    <groupId>org.mybatis</groupId>
    </exclusion>
    <exclusion>
    <artifactId>mybatis</artifactId>
    <groupId>org.mybatis</groupId>
    </exclusion>
    </exclusions>
    </dependency>
    </dependencies>

    service层
        @Override
        public PageInfo<SysHospital> sysHospitalList(SearchHospitalListReq req) {
            PageHelper.startPage(req.getPageNum(), req.getPageSize());
            Example example = new Example(SysHospital.class);
            Example.Criteria criteria = example.createCriteria().andEqualTo("deleteFlag", DeleteFlagEnum.NORMAL.getCode())
                    .andEqualTo("hospitalType",req.getHospitalType());
            example.setOrderByClause("create_time desc");
            List<SysHospital> sysHospitals = sysHospitalMapper.selectByExample(example);
            PageInfo pageInfo = PageInfo.of(sysHospitals);
            pageInfo.setList(sysHospitals);
            return pageInfo;
        }
    

      

  • 相关阅读:
    面向对象之单例模式
    面向对象之元类
    面向对象高级1
    面向对象进阶2
    面向对象进阶1
    面向对象基础
    MySQL事务
    【应用容器引擎】Docker笔记
    【Spring Boot】三、嵌入式的Servlet容器
    MySQL优化分析
  • 原文地址:https://www.cnblogs.com/yxj808/p/15044509.html
Copyright © 2020-2023  润新知