解决能力集市 筛选各类排序失效(内部二级缓存)

This commit is contained in:
wangliwen 2022-07-08 09:18:03 +08:00
parent ec6597ba35
commit 0f980cf238
3 changed files with 7 additions and 5 deletions

View File

@ -23,7 +23,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
Integer deleteByIds(@Param("ids") List<Long> idList);
@Cacheable(value = "selectWithAttrs", key = "#p0")
@Cacheable(value = "selectWithAttrs", key = "#p0+'-'+#orderField+'-'+#orderType")
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO,
@Param("orderField") String orderField,
@Param("orderType") String orderType);

View File

@ -407,7 +407,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}).reversed()).collect(Collectors.toList()));
} else {
resultPage.setRecords(resourceDTOS.stream().sorted(Comparator.comparing(x -> {
ResourceDTO index = (ResourceDTO) x;
ResourceDTO index = x;
return index.getTotal() == null ? 0L : index.getTotal();
})).collect(Collectors.toList()));
}
@ -417,6 +417,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
resultPage.setRecords(resourceDTOS);
resultPage.setTotal(resourceDao.selectDTOPageCount(resourceDTO));
} else {
logger.info("orderField:{} orderType:{}", orderField, orderType);
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
if (resourceDTOS.isEmpty()) {

View File

@ -123,10 +123,8 @@
AND tdr.del_flag = 0
<if test="dto.type != null and dto.type != ''">
AND MATCH (tdr.type) AGAINST ( #{dto.type} IN BOOLEAN MODE)
<!--AND tdr.type LIKE CONCAT('%',#{dto.type},'%') -->
</if>
<if test="dto.name != null and dto.name != ''">
<!-- AND tdr.name LIKE CONCAT('%',#{dto.name},'%') -->
AND MATCH (tdr.name) AGAINST ( #{dto.name} IN BOOLEAN MODE)
</if>
<if test="dto.districtId != null and dto.districtId != ''">
@ -162,7 +160,9 @@
) tmp
)
</if>
ORDER BY ${orderField} ${orderType}
<if test="orderField != null and orderField !=''">
ORDER BY ${orderField} ${orderType}
</if>
</select>
<select id="selectTypeCount" resultType="java.util.Map">
@ -428,6 +428,7 @@
<if test="dto.deptId != null and dto.deptId != ''">
AND tdr.dept_id = #{dto.deptId}
</if>
ORDER BY create_date DESC
</select>
<select id="selectDTOPageCount" resultType="java.lang.Long">