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

@@ -32,11 +32,11 @@
<scope>test</scope>
</dependency>

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

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

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

@@ -23,5 +23,5 @@ public interface TenantMapper {

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

@@ -4,6 +4,8 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.constant.HhzUrlConstant;
import com.tuoheng.mapper.*;
@@ -252,11 +254,11 @@ public class ClientUserServiceImpl implements ClientUserSevice {
if (ObjectUtil.isNull(query.getPage()) || ObjectUtil.isNull(query.getLimit())) {
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<>();
for (TenantPo tenantPo : records) {
for (TenantPo tenantPo : tenantList) {
TenantVo vo = new TenantVo();
vo.setCode(tenantPo.getCode());
vo.setName(tenantPo.getName());
@@ -278,10 +280,9 @@ public class ClientUserServiceImpl implements ClientUserSevice {
vo.setList(businessSystemVoList);
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