|
|
@@ -1,5 +1,6 @@
|
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.izouma.nineth.config.Constants;
|
|
|
import com.izouma.nineth.domain.Asset;
|
|
|
@@ -26,14 +27,25 @@ public class UserHoldCountService {
|
|
|
|
|
|
private CollectionRepo collectionRepo;
|
|
|
|
|
|
- @Cacheable(value = "userHoldList", key = "#pageQuery.hashCode()")
|
|
|
+// @Cacheable(value = "userHoldList", key = "#pageQuery.hashCode()")
|
|
|
public PageWrapper<UserHoldDTO> all(PageQuery pageQuery) {
|
|
|
int page = pageQuery.getPage();
|
|
|
int size = pageQuery.getSize();
|
|
|
int start = page * size;
|
|
|
- Map<String, BigDecimal> minPriceMap = new HashMap<>();
|
|
|
int totalElements = assetRepo.totalElements();
|
|
|
- List<Map<String, String>> assets = assetRepo.findByPage(start, size);
|
|
|
+ List<UserHoldDTO> userHoldDTOS = allUserHold();
|
|
|
+ if (CollUtil.isNotEmpty(userHoldDTOS)) {
|
|
|
+ userHoldDTOS.sort(Comparator.comparing(UserHoldDTO::getPrice).reversed());
|
|
|
+ }
|
|
|
+ List<UserHoldDTO> newUserHoldList = userHoldDTOS.subList(start, start + size);
|
|
|
+ return new PageWrapper<>(newUserHoldList, page,
|
|
|
+ size, totalElements);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Cacheable(value = "userHoldList")
|
|
|
+ public List<UserHoldDTO> allUserHold() {
|
|
|
+ Map<String, BigDecimal> minPriceMap = new HashMap<>();
|
|
|
+ List<Map<String, String>> assets = assetRepo.findAllUserHold();
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
jsonArray.addAll(assets);
|
|
|
List<UserHoldDTO> userHoldDTOS = jsonArray.toJavaList(UserHoldDTO.class);
|
|
|
@@ -63,10 +75,8 @@ public class UserHoldCountService {
|
|
|
calculatePrice(userHoldDTO, asset, minPriceMap, null, null);
|
|
|
});
|
|
|
});
|
|
|
- return new PageWrapper<>(userHoldDTOS, page,
|
|
|
- size, totalElements);
|
|
|
+ return userHoldDTOS;
|
|
|
}
|
|
|
-
|
|
|
private void calculatePrice(UserHoldDTO userHoldDTO, Asset asset, Map<String, BigDecimal> minPriceMap, String nameLike, String nameNotLike) {
|
|
|
BigDecimal minPrice;
|
|
|
String minPriceMapKey = StringUtils.isBlank(nameLike) ? asset.getPrefixName() : asset.getPrefixName().concat(nameLike);
|