Pārlūkot izejas kodu

更新分页查询方式

tags/v2.5.3
xiaoying pirms 11 mēnešiem
vecāks
revīzija
d280bb5807
3 mainītis faili ar 9 papildinājumiem un 13 dzēšanām
  1. +2
    -1
      tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java
  2. +6
    -11
      tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java
  3. +1
    -1
      tuoheng_oidc_admin/src/main/resources/mapper/TenantMapper.xml

+ 2
- 1
tuoheng_oidc_admin/src/main/java/com/tuoheng/mapper/TenantMapper.java Parādīt failu

@@ -1,6 +1,7 @@
package com.tuoheng.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tuoheng.model.dto.OidcTenantDto;
import com.tuoheng.model.dto.TTenant;
import com.tuoheng.model.po.TenantPo;
@@ -24,7 +25,7 @@ public interface TenantMapper {

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

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

void updateById(TenantPo tenantPo);


+ 6
- 11
tuoheng_oidc_admin/src/main/java/com/tuoheng/service/impl/TenantServiceImpl.java Parādīt failu

@@ -331,8 +331,10 @@ public class TenantServiceImpl implements TenantService {
//分页参数校验
query.checkParam();
//开启分页
List<TenantVo> tenantVos = tenantMapper.findList(query);
List<TenantVo> collect = tenantVos.stream().map(x -> {
// 设置分页参数
IPage<TenantVo> pageDate = new Page<>(query.getPage(), query.getLimit());
IPage<TenantVo> tenantVos = tenantMapper.findListByPage(pageDate,query);
List<TenantVo> collect = tenantVos.getRecords().stream().map(x -> {
TenantVo vo = new TenantVo();
BeanUtils.copyProperties(x, vo);
//并不是真正意义上的租户id
@@ -383,15 +385,8 @@ public class TenantServiceImpl implements TenantService {
vo.setList(businessSystemVoList);
return vo;
}).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));
pageDate.setRecords(collect);
return JsonResult.success(pageDate);
}

/**

+ 1
- 1
tuoheng_oidc_admin/src/main/resources/mapper/TenantMapper.xml Parādīt failu

@@ -42,7 +42,7 @@
where code = #{code}
and enabled = 1
</select>
<select id="findList" resultType="com.tuoheng.model.vo.TenantVo">
<select id="findListByPage" resultType="com.tuoheng.model.vo.TenantVo">
SELECT t.id, t.user_id userId, t.remark, t.code tenantCode,
t.name tenantName,t.customer,t.customer_phone
,t.province_code,t.province_name,t.city_code,t.city_name,t.district_code,t.district_name,u.username

Notiek ielāde…
Atcelt
Saglabāt