|
|
@@ -1,5 +1,7 @@
|
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.izouma.nineth.TokenHistory;
|
|
|
import com.izouma.nineth.config.GeneralProperties;
|
|
|
import com.izouma.nineth.domain.Collection;
|
|
|
@@ -51,7 +53,18 @@ public class AssetService {
|
|
|
private GeneralProperties generalProperties;
|
|
|
|
|
|
public Page<Asset> all(PageQuery pageQuery) {
|
|
|
- return assetRepo.findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
+ Page<Asset> all = assetRepo.findAll(JpaUtils.toSpecification(pageQuery, Asset.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
+ Map<String, Object> query = pageQuery.getQuery();
|
|
|
+ if (ObjectUtil.isNotEmpty(query.get("userId"))) {
|
|
|
+ List<Long> assetId = orderRepo.findAllByUserIdAndOpenedFalse(Convert.convert(Long.class, query.get("userId")));
|
|
|
+ return all.map(asset -> {
|
|
|
+ if (assetId.contains(asset.getId())){
|
|
|
+ asset.setOpened(false);
|
|
|
+ }
|
|
|
+ return asset;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return all;
|
|
|
}
|
|
|
|
|
|
public Asset createAsset(Collection collection, User user, Long orderId, BigDecimal price, String type, Integer number) {
|