浏览代码

update:本地库查询采用分页查询插件v1

lvzhiqiang 2 年之前
父节点
当前提交
6657e47a94

+ 1 - 1
src/main/java/top/lvzhiqiang/controller/CoinController.java

@@ -47,7 +47,7 @@ public class CoinController {
      * 2023/9/5 15:23
      */
     @PostMapping("/mainSearch")
-    public JSONArray mainSearch(@RequestBody JSONObject params) throws Exception {
+    public Object mainSearch(@RequestBody JSONObject params) throws Exception {
         if (!params.containsKey("nameEn")) {
             throw new ParameterException("参数错误!");
         }

+ 1 - 1
src/main/java/top/lvzhiqiang/service/CoinService.java

@@ -25,7 +25,7 @@ public interface CoinService {
      * @param params
      * @return
      */
-    JSONArray mainSearch(JSONObject params) throws Exception;
+    Object mainSearch(JSONObject params) throws Exception;
 
     void syncData(String startTime, String endTime, String pageSize);
 

+ 10 - 4
src/main/java/top/lvzhiqiang/service/impl/CoinServiceImpl.java

@@ -1,9 +1,9 @@
 package top.lvzhiqiang.service.impl;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import me.chanjar.weixin.common.error.WxErrorException;
 import me.chanjar.weixin.cp.api.WxCpGroupRobotService;
@@ -628,7 +628,7 @@ public class CoinServiceImpl implements CoinService {
     }
 
     @Override
-    public JSONArray mainSearch(JSONObject params) throws Exception {
+    public Object mainSearch(JSONObject params) throws Exception {
         JSONArray result = new JSONArray();
         if (params.getString("nameEn").equals("allPositionv2")) {
             Map<String, String> paramMap = new HashMap<>();
@@ -657,14 +657,20 @@ public class CoinServiceImpl implements CoinService {
             PageHelper.startPage(params.getInteger("pageNo"), params.getInteger("pageSize"), true);
             List<CoinHistoryOrder> historyOrderList = coinMapper.findHistoryOrderList(params.toJavaObject(Map.class));
 
+            PageInfo<CoinHistoryOrder> historyOrderPageInfo = new PageInfo<>(historyOrderList);
+
             renderMainSearch4OrderHistoryProductType(historyOrderList);
-            result = (JSONArray) JSON.toJSON(historyOrderList);
+            //result = (JSONArray) JSON.toJSON(historyOrderList);
+            return historyOrderPageInfo;
         } else if (params.getString("nameEn").equals("traderList")) {
             PageHelper.startPage(params.getInteger("pageNo"), params.getInteger("pageSize"), true);
             List<CoinTrader> mixTraderList = coinMapper.findMixTraderList(params.toJavaObject(Map.class));
 
+            PageInfo<CoinTrader> coinTraderPageInfo = new PageInfo<>(mixTraderList);
+
             renderMainSearch4TraderList(mixTraderList);
-            result = (JSONArray) JSON.toJSON(mixTraderList);
+            //result = (JSONArray) JSON.toJSON(mixTraderList);
+            return coinTraderPageInfo;
         } else if (params.getString("nameEn").equals("monitorCurrency")) {
             List<String> monitorCurrencyList = coinMapper.findMonitorCurrencyList();
 

+ 4 - 2
src/main/resources/static/coin.html

@@ -136,8 +136,9 @@
         <div id="apis-quiet-div-traderList" style="display: none;">
             <button class="apis-quiet-div-button3" slideDiv="apis-quiet-content" pageO="prev">上一页</button>
             <button class="apis-quiet-div-button3" slideDiv="apis-quiet-content" pageO="next">下一页</button>
-            <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-traderList-pageNo" disabled="disabled" value="1">
+            <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-traderList-pageNo" value="1">
             <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-traderList-pageSize" disabled="disabled" value="30">
+            <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-traderList-pages" disabled="disabled" value="999999">
             <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-traderList-keyword" placeholder="昵称关键词">
             <select id="apis-quiet-div-traderList-sortField" style="height: 24px;">
                 <option value="lastTradeTime">最近交易时间</option>
@@ -169,8 +170,9 @@
         <div id="apis-quiet-div-orderHistoryProductType" style="display: none;">
             <button class="apis-quiet-div-button3" slideDiv="apis-quiet-content" pageO="prev">上一页</button>
             <button class="apis-quiet-div-button3" slideDiv="apis-quiet-content" pageO="next">下一页</button>
-            <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-orderHistoryProductType-pageNo" disabled="disabled" value="1">
+            <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-orderHistoryProductType-pageNo" value="1">
             <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-orderHistoryProductType-pageSize" disabled="disabled" value="30">
+            <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-orderHistoryProductType-pages" disabled="disabled" value="999999">
             <input type="text" style="width: 100px;padding-top: 3px;" id="apis-quiet-div-orderHistoryProductType-keyword" placeholder="币对关键词">
             <select id="apis-quiet-div-orderHistoryProductType-sortField" style="height: 24px;">
                 <option value="cTime">创建时间</option>

+ 11 - 3
src/main/resources/static/js/my-coin.js

@@ -221,7 +221,9 @@ function handleSelectChange(objj) {
                         $(pageNoVar).val(Number(beforePageNo) - 1);
                     }
                 } else if (pageO === 'next') {
-                    $(pageNoVar).val(Number(beforePageNo) + 1);
+                    if (beforePageNo < Number($("#apis-quiet-div-" + nameEn).find("input[id$=pages]").val())) {
+                        $(pageNoVar).val(Number(beforePageNo) + 1);
+                    }
                 }
 
                 mainSearch(url, nameEn, slideDiv, "2");
@@ -279,8 +281,14 @@ function mainSearch(url, nameEn, slideDiv, needCustomFlag) {
                     return;
                 }
 
-                data = data.data;
-                $('#' + slideDiv).find("span.contentSPAN").html(data.length);
+                if (nameEn === 'orderHistoryProductType' || nameEn === 'traderList') {
+                    $("#apis-quiet-div-" + nameEn).find("input[id$=pages]").val(data.data.pages);
+                    $('#' + slideDiv).find("span.contentSPAN").html(data.data.total);
+                    data = data.data.list;
+                } else {
+                    data = data.data;
+                    $('#' + slideDiv).find("span.contentSPAN").html(data.length);
+                }
 
                 var returnEn = '';
                 if (needCustomFlag === '1') {