liaijie 3 лет назад
Родитель
Сommit
4c6259b0af
1 измененных файлов с 26 добавлено и 8 удалено
  1. 26 8
      src/main/java/com/izouma/nineth/service/AssetService.java

+ 26 - 8
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -421,7 +421,7 @@ public class AssetService {
         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);
-            //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 {
@@ -431,9 +431,28 @@ public class AssetService {
                     and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("fromUserId"), userId)));
                 }
             }
-            /*if (ObjectUtils.isNotEmpty(query.get("operation"))){
-                and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"),operation)));
-            }*/
+            if (ObjectUtils.isNotEmpty(query.get("operation"))){
+                if (operation.equals("买入")){
+                    log.error("进了买入里了=========");
+                    operation="出售";
+                    boolean operation1 = and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"), operation)));
+                    log.error("第一次添加========="+operation1);
+                    operation="转让";
+                    boolean operation2 =and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"),operation)));
+                    log.error("第二次添加========="+operation2);
+                    operation="空投";
+                    boolean operation3 =and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"),operation)));
+                    log.error("第三次添加========="+operation3);
+                }else if (operation.equals("卖出")){
+                    operation="转让";
+                    boolean operation1 = and.add(criteriaBuilder.and(criteriaBuilder.equal(root.get("operation"), operation)));
+                    log.error("进入卖出========="+operation1);
+                }else {
+                    operation="转赠";
+                    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));
 
@@ -463,13 +482,12 @@ public class AssetService {
 
             return userHistory;
         });
-
-        Object operation1 = query.get("operation");
+       /* Object operation1 = query.get("operation");
         boolean b = null != operation1;
         log.error("是否进入"+b);
         if (null!=operation1){
             String operation =  operation1.toString();
-            List<UserHistory> content = map.toList();
+            List<UserHistory> content = map.getContent();
             log.error("总长度为"+content.size());
             for (int i = 0; i < content.size(); i++) {
                 log.error("传过来的值为:"+operation);
@@ -482,7 +500,7 @@ public class AssetService {
             }
             Pageable pageable = PageRequest.of(pageQuery.getPage(), pageQuery.getSize());
             map = PageUtil.createPageFromList(content, pageable);
-        }
+        }*/
         return map;
     }