selectWithAttrs 减少sql返回字段

This commit is contained in:
wangliwen 2022-06-28 09:27:35 +08:00
parent 5176f58ac8
commit 73f0607099
2 changed files with 17 additions and 34 deletions

View File

@ -256,7 +256,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultPage.setTotal(0);
} else {
List<ResourceDTO> recordLists = resourceDTOS.stream()
.skip((pageNum - 1) * pageSize).limit(pageSize).collect(Collectors.toList());
.skip((pageNum - 1) * pageSize).limit(pageSize)
.map(dto_ -> {
ResourceDTO temp = dto_;
this.get(dto_.getId());
BeanUtils.copyProperties(temp, dto_);
dto_.setInfoList(temp.getInfoList());
return dto_;
}).collect(Collectors.toList());
resultPage.setRecords(recordLists);
resultPage.setTotal(resourceDTOS.size());
}
@ -319,10 +326,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultPage.setRecords(null);
resultPage.setTotal(0);
} else {
ArrayList<ResourceDTO> recordLists = new ArrayList<>();
for (int i = (pageNum - 1) * pageSize; i < j; i++) {
recordLists.add(resourceDTOS.get(i));
}
List<ResourceDTO> recordLists = resourceDTOS.stream()
.skip((pageNum - 1) * pageSize).limit(pageSize)
.map(dto_ -> {
ResourceDTO temp = dto_;
this.get(dto_.getId());
BeanUtils.copyProperties(temp, dto_);
dto_.setInfoList(temp.getInfoList());
return dto_;
}).collect(Collectors.toList());
resultPage.setRecords(recordLists);
resultPage.setTotal(resourceDTOS.size());
}

View File

@ -106,35 +106,6 @@
<select id="selectWithAttrs" resultMap="resourceDTO">
SELECT
DISTINCT tdr.id,
tdr.`type`,
tdr.`name`,
tdr.description,
tdr.link,
tdr.api_method_type,
tdr.api_url,
tdr.group_id,
tdr.dept_id,
tdr.dept_contacts,
tdr.dept_phone,
tdr.share_type,
tdr.share_mode,
tdr.share_condition,
tdr.district_id,
tdr.visits,
tdr.del_flag,
tdr.creator,
tdr.create_date,
tdr.updater,
tdr.update_date,
tdr.note1,
tdr.note2,
tdr.note3,
tdr.note4,
tdr.note5,
tdr.enclosure,
tdr.undercarriage_reason,
tdr.undercarriage_user_name,
tdr.info_list,
IFNULL(taa2.approve_status, '未申请') AS "applyState",
IFNULL(trs.score, 0 ) AS "score",
IFNULL(taa.applyCount, 0 ) AS "applyCount",