Explorar o código

update:watchlist 优先级排序加入优先级相同取涨幅排序v1

tujidelv hai 1 ano
pai
achega
075dccc0a0

+ 4 - 1
src/main/java/top/lvzhiqiang/mapper/CoinMapper.java

@@ -94,7 +94,10 @@ public interface CoinMapper {
             "<if test=\"trackCategoryField != null and trackCategoryField != ''\">" +
             "   and track_category like concat('%',#{trackCategoryField},'%')" +
             "</if>" +
-            " order by ${sortField} ${sort}" +
+            " order by " +
+            "<foreach collection='sortField' item='sf' index=\"index\" separator=\",\">" +
+            "   ${sf} ${sort}" +
+            " </foreach>" +
             "</script>"})
     List<CoinWatchlist> findWatchlistList(Map<String, Object> params);
 

+ 17 - 0
src/main/java/top/lvzhiqiang/service/impl/CoinServiceImpl.java

@@ -852,11 +852,23 @@ public class CoinServiceImpl implements CoinService {
             int MAX_NUMBER = 100;
             Stream.iterate(0, n -> n + 1).limit((watchlistList.size() + MAX_NUMBER - 1) / MAX_NUMBER)
                     .forEach(i -> {
+                        try {
+                            Thread.sleep(2000L);
+                        } catch (InterruptedException e) {
+                            throw new RuntimeException(e);
+                        }
+
                         Map<String, CoinWatchlist> coinWatchlistMap4CoingeckoId = watchlistList.stream().skip((long) i * MAX_NUMBER).limit(MAX_NUMBER).collect(Collectors.toMap(CoinWatchlist::getCoingeckoId, coinWatchlist -> coinWatchlist));
                         parseWatchlistMap4Coingecko(coinWatchlistMap4CoingeckoId);
                     });
             Stream.iterate(0, n -> n + 1).limit((watchlistList.size() + MAX_NUMBER - 1) / MAX_NUMBER)
                     .forEach(i -> {
+                        try {
+                            Thread.sleep(2000L);
+                        } catch (InterruptedException e) {
+                            throw new RuntimeException(e);
+                        }
+
                         Map<Long, CoinWatchlist> coinWatchlistMap4CmcId = watchlistList.stream().skip((long) i * MAX_NUMBER).limit(MAX_NUMBER).collect(Collectors.toMap(CoinWatchlist::getCmcId, coinWatchlist -> coinWatchlist));
                         parseWatchlistMap4CmC(coinWatchlistMap4CmcId);
                     });
@@ -1342,6 +1354,11 @@ public class CoinServiceImpl implements CoinService {
             return coinTraderPageInfo;
         } else if (params.getString("nameEn").equals("watchlist")) {
             PageHelper.startPage(params.getInteger("pageNo"), params.getInteger("pageSize"), true);
+
+            if (params.containsKey("sortField")) {
+                params.put("sortField", Arrays.asList(params.getString("sortField").split(",")));
+            }
+
             List<CoinWatchlist> watchlistList = coinMapper.findWatchlistList(params.toJavaObject(Map.class));
 
             PageInfo<CoinWatchlist> watchlistPageInfo = new PageInfo<>(watchlistList);

+ 1 - 1
src/main/resources/static/coin.html

@@ -285,7 +285,7 @@
             </select>
             <select id="apis-quiet-div-watchlist-sortField" style="height: 24px;">
                 <option value="price_change_percentage_24h">24H涨跌幅</option>
-                <option value="score">优先级</option>
+                <option value="score,price_change_percentage_24h">优先级</option>
                 <option value="total_market_value">流通市值</option>
                 <option value="total_market_ranking">市值排名</option>
                 <option value="increase_multiple">涨幅倍数</option>