|
|
@@ -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;
|
|
|
@@ -414,9 +418,10 @@ public class AssetService {
|
|
|
}
|
|
|
|
|
|
public Page<UserHistory> userHistory(Long userId, PageQuery pageQuery) {
|
|
|
+ Map<String, Object> query = pageQuery.getQuery();
|
|
|
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");
|
|
|
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 {
|
|
|
@@ -426,9 +431,7 @@ public class AssetService {
|
|
|
and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("fromUserId"), userId)));
|
|
|
}
|
|
|
}
|
|
|
- Object operation4 = query.get("operation");
|
|
|
- if (ObjectUtils.isNotEmpty(operation4)){
|
|
|
- String operation = (String) query.get("operation");
|
|
|
+ /* if (ObjectUtils.isNotEmpty(query.get("operation"))){
|
|
|
if (operation.equals("买入")){
|
|
|
log.error("进了买入里了=========");
|
|
|
operation="出售";
|
|
|
@@ -449,14 +452,14 @@ public class AssetService {
|
|
|
boolean operation1 = and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"), operation)));
|
|
|
log.error("进入转赠========="+operation1);
|
|
|
}
|
|
|
- }
|
|
|
+ }*/
|
|
|
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);
|
|
|
|
|
|
- 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()))
|
|
|
@@ -476,8 +479,29 @@ public class AssetService {
|
|
|
userHistory.setDescription("赠送");
|
|
|
break;
|
|
|
}
|
|
|
+
|
|
|
return userHistory;
|
|
|
});
|
|
|
+ Object operation1 = query.get("operation");
|
|
|
+ boolean b = null != operation1;
|
|
|
+ log.error("是否进入"+b);
|
|
|
+ if (null!=operation1){
|
|
|
+ String operation = operation1.toString();
|
|
|
+ List<UserHistory> content = map.getContent();
|
|
|
+ log.error("总长度为"+content.size());
|
|
|
+ for (int i = 0; i < content.size(); i++) {
|
|
|
+ log.error("传过来的值为:"+operation);
|
|
|
+ log.error("原来的的值为:"+content.get(i).getDescription());
|
|
|
+ log.error("=================");
|
|
|
+ if (!content.get(i).getDescription().equals(operation)){
|
|
|
+ content.remove(i);
|
|
|
+ i--;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Pageable pageable = PageRequest.of(pageQuery.getPage(), pageQuery.getSize());
|
|
|
+ map = PageUtil.createPageFromList(content, pageable);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
public String mint(LocalDateTime time) {
|