Browse Source

开启分页插件进行分页

tags/v2.4.0
xiaoying 1 year ago
parent
commit
b8e474b0c6
5 changed files with 17 additions and 10 deletions
  1. +8
    -2
      tuoheng_oidc_admin/pom.xml
  2. +1
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java
  3. +8
    -7
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java
  4. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/TenantMapper.class
  5. BIN
      tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientUserServiceImpl.class

+ 8
- 2
tuoheng_oidc_admin/pom.xml View File

<scope>test</scope> <scope>test</scope>
</dependency> </dependency>


<!--mybatis-plus-->
<!--mybatis-plus 起始依赖 -->
<dependency> <dependency>
<groupId>com.baomidou</groupId> <groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId> <artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.2</version>
<version>3.2.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.hutool</groupId> <groupId>cn.hutool</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency> </dependency>


<!--分页插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>

+ 1
- 1
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java View File



TTenant getByCode(@Param("code") String code); TTenant getByCode(@Param("code") String code);


IPage<TenantPo> findList(@Param("page") IPage<TenantVo> page, TenantQuery query);
List<TenantPo> findList(@Param("query") TenantQuery query);
} }

+ 8
- 7
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/ClientUserServiceImpl.java View File

import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tuoheng.common.ServiceException; import com.tuoheng.common.ServiceException;
import com.tuoheng.constant.HhzUrlConstant; import com.tuoheng.constant.HhzUrlConstant;
import com.tuoheng.mapper.*; import com.tuoheng.mapper.*;
if (ObjectUtil.isNull(query.getPage()) || ObjectUtil.isNull(query.getLimit())) { if (ObjectUtil.isNull(query.getPage()) || ObjectUtil.isNull(query.getLimit())) {
return JsonResult.error("分页参数不能为空"); return JsonResult.error("分页参数不能为空");
} }
IPage<TenantVo> page = new Page<>(query.getPage(), query.getLimit());
IPage<TenantPo> tenantList = tenantMapper.findList(page, query);
List<TenantPo> records = tenantList.getRecords();
//开启分页
PageHelper.startPage(query.getPage(),query.getLimit());
List<TenantPo> tenantList = tenantMapper.findList(query);
List<TenantVo> list = new ArrayList<>(); List<TenantVo> list = new ArrayList<>();
for (TenantPo tenantPo : records) {
for (TenantPo tenantPo : tenantList) {
TenantVo vo = new TenantVo(); TenantVo vo = new TenantVo();
vo.setCode(tenantPo.getCode()); vo.setCode(tenantPo.getCode());
vo.setName(tenantPo.getName()); vo.setName(tenantPo.getName());
vo.setList(businessSystemVoList); vo.setList(businessSystemVoList);
list.add(vo); list.add(vo);
} }
page.setRecords(list);
page.setTotal(list.size());
PageInfo<TenantVo> tenantVoPageInfo = new PageInfo<>(list);


return JsonResult.success(page);
return JsonResult.success(tenantVoPageInfo);
} }





BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/mapper/TenantMapper.class View File


BIN
tuoheng_oidc_admin/target/classes/com/tuoheng/service/impl/ClientUserServiceImpl.class View File


Loading…
Cancel
Save