ouyang 3 роки тому
батько
коміт
b2680876f5

+ 5 - 6
src/main/java/com/izouma/nineth/domain/Result.java

@@ -8,6 +8,8 @@ import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.formula.functions.T;
 
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
 import java.util.List;
 
 @Data
@@ -18,6 +20,8 @@ public class Result<T> {
     private int code;
     //提示信息
     private String msg;
+    //当前时候毫秒值
+    private String time;
     // 返回对象
     private List<T> data;
 
@@ -60,17 +64,12 @@ public class Result<T> {
         this.msg = sysCode.getMsg();
     }
 
-
-    public Result(int code, String msg) {
-        this(code, msg, null);
-    }
-
     public void setSystemCode(SystemCode sysCode) {
         this.code = sysCode.getCode();
         this.msg = sysCode.getMsg();
     }
 
     public  Result<T> success(List<T> data){
-        return new Result<>(SystemCode.SUCCESS.getCode(), SystemCode.SUCCESS.getMsg(),data);
+        return new Result<T>(SystemCode.SUCCESS.getCode(), SystemCode.SUCCESS.getMsg(),String.valueOf(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"))),data);
     }
 }

+ 6 - 0
src/main/java/com/izouma/nineth/repo/CollectionRepo.java

@@ -172,6 +172,12 @@ public interface CollectionRepo extends JpaRepository<Collection, Long>, JpaSpec
             "and c.stock > 0 order by c.original_price limit 1", nativeQuery = true)
     String lowestOriginPrice(String search);
 
+    @Query(value = "select min(t.price) from (select c.price from collection_info c where c.name like ?1 " +
+            "and c.source = 'TRANSFER' " +
+            "and c.salable = true " +
+            "and c.stock > 0 order by c.price limit 5) t", nativeQuery = true)
+    String lowestPrices(String search);
+
     @Query("select c from Collection c join c.tags t on t.id = ?1 ")
     Page<Collection> byTag(Long tagId, Pageable pageable);
 

+ 2 - 2
src/main/java/com/izouma/nineth/web/PriceListController.java

@@ -99,8 +99,8 @@ public class PriceListController extends BaseController {
             list.add(new PriceListVo().builder()
                     .name(priceList.getName())
                     .img(priceList.getPic())
-                    .price(priceList.getPrice())
-                    .origin_price((collectionRepo.lowestOriginPrice(priceList.getSearch())))
+                    .price(collectionRepo.lowestPrices(priceList.getSearch()))
+                    .origin_price(collectionRepo.lowestOriginPrice(priceList.getSearch()))
                     .build());
         }
          return Result.OK().success(list);