Browse Source

更新分页查询

tags/v2.5.0
xiaoying 1 year ago
parent
commit
62f2d6bc14
2 changed files with 13 additions and 6 deletions
  1. +1
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java
  2. +12
    -5
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java

+ 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<TenantVo> findList(@Param("page") IPage<TenantVo> page, @Param("query") TenantQuery query);
List<TenantVo> findList(@Param("query") TenantQuery query);


void updateById(TenantPo tenantPo); void updateById(TenantPo tenantPo);



+ 12
- 5
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java View File

//分页参数校验 //分页参数校验
query.checkParam(); query.checkParam();
//开启分页 //开启分页
IPage<TenantVo> page = new Page<>(query.getPage(), query.getLimit());
IPage<TenantVo> pageData = tenantMapper.findList(page, query);
pageData.convert(x -> {
List<TenantVo> tenantVos = tenantMapper.findList(query);
List<TenantVo> collect = tenantVos.stream().map(x -> {
TenantVo vo = new TenantVo(); TenantVo vo = new TenantVo();
BeanUtils.copyProperties(x, vo); BeanUtils.copyProperties(x, vo);
//并不是真正意义上的租户id //并不是真正意义上的租户id
businessSystemVoList = businessSystemVoList.stream().distinct().collect(Collectors.toList()); businessSystemVoList = businessSystemVoList.stream().distinct().collect(Collectors.toList());
vo.setList(businessSystemVoList); vo.setList(businessSystemVoList);
return vo; return vo;
});
return JsonResult.success(pageData);
}).filter(x -> x != null).collect(Collectors.toList());
//粗暴的分页
Integer pageNum = query.getPage();
Integer pageSize = query.getLimit();
int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, collect.size());
List<TenantVo> subList = collect.subList(startIndex, endIndex);
IPage<TenantVo> page = new Page<>(pageNum, pageSize);
page.setTotal(collect.size());
return JsonResult.success(page.setRecords(subList));
} }


/** /**

Loading…
Cancel
Save