|
|
@@ -15,10 +15,12 @@ import com.izouma.nineth.event.TransferAssetEvent;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.*;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
+import com.izouma.nineth.utils.PageUtil;
|
|
|
import com.izouma.nineth.utils.SecurityUtils;
|
|
|
import com.izouma.nineth.utils.TokenUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import net.coobird.thumbnailator.filters.Pipeline;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
|
|
@@ -26,6 +28,8 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
+import org.springframework.data.domain.PageImpl;
|
|
|
+import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -417,7 +421,7 @@ public class AssetService {
|
|
|
Page<TokenHistory> page = tokenHistoryRepo.findAll(((root, criteriaQuery, criteriaBuilder) -> {
|
|
|
List<Predicate> and = JpaUtils.toPredicates(pageQuery, TokenHistory.class, root, criteriaQuery, criteriaBuilder);
|
|
|
Map<String, Object> query = pageQuery.getQuery();
|
|
|
- String operation = (String) query.get("operation");
|
|
|
+ //String operation = (String) query.get("operation");
|
|
|
if (ObjectUtils.isEmpty(query.get("toUserId")) && ObjectUtils.isEmpty(query.get("fromUserId"))) {
|
|
|
and.add(criteriaBuilder.or(criteriaBuilder.equal(root.get("toUserId"), userId), criteriaBuilder.equal(root.get("fromUserId"), userId)));
|
|
|
} else {
|
|
|
@@ -427,16 +431,18 @@ public class AssetService {
|
|
|
and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("fromUserId"), userId)));
|
|
|
}
|
|
|
}
|
|
|
- if (ObjectUtils.isNotEmpty(query.get("operation"))){
|
|
|
+ /*if (ObjectUtils.isNotEmpty(query.get("operation"))){
|
|
|
and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"),operation)));
|
|
|
- }
|
|
|
+ }*/
|
|
|
return criteriaBuilder.and(and.toArray(new Predicate[0]));
|
|
|
}), JpaUtils.toPageRequest(pageQuery));
|
|
|
|
|
|
Set<String> tokenIds = page.stream().map(TokenHistory::getTokenId).collect(Collectors.toSet());
|
|
|
List<Asset> assets = tokenIds.isEmpty() ? new ArrayList<>() : assetRepo.findByTokenIdIn(tokenIds);
|
|
|
+ Map<String, Object> query = pageQuery.getQuery();
|
|
|
+ String operation = (String) query.get("operation");
|
|
|
|
|
|
- return page.map(tokenHistory -> {
|
|
|
+ Page<UserHistory> map = page.map(tokenHistory -> {
|
|
|
UserHistory userHistory = new UserHistory();
|
|
|
BeanUtils.copyProperties(tokenHistory, userHistory);
|
|
|
Optional<Asset> asset = assets.stream().filter(a -> a.getTokenId().equals(tokenHistory.getTokenId()))
|
|
|
@@ -456,8 +462,19 @@ public class AssetService {
|
|
|
userHistory.setDescription("赠送");
|
|
|
break;
|
|
|
}
|
|
|
+ if (operation != null && operation != "") {
|
|
|
+ if (!userHistory.getOperation().equals(operation)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
return userHistory;
|
|
|
});
|
|
|
+
|
|
|
+ List<UserHistory> content = map.getContent();
|
|
|
+ content.removeAll(Collections.singleton(null));
|
|
|
+ Pageable pageable = PageRequest.of(pageQuery.getPage() - 1, pageQuery.getSize());
|
|
|
+ Page<UserHistory> pageFromList = PageUtil.createPageFromList(content, pageable);
|
|
|
+ return pageFromList;
|
|
|
}
|
|
|
|
|
|
public String mint(LocalDateTime time) {
|