chen_yjin 3 月之前
父節點
當前提交
4955c61f96
共有 3 個文件被更改,包括 34 次插入1 次删除
  1. 3 0
      JLHHJSvr/Com/GetERPMtrldefList.cs
  2. 5 1
      JLHHJSvr/Excutor/GetERPMtrldefListExcutor.cs
  3. 26 0
      JLHHJSvr/Helper/ERPHelper.cs

+ 3 - 0
JLHHJSvr/Com/GetERPMtrldefList.cs

@@ -54,5 +54,8 @@ namespace JLHHJSvr.Com
     public sealed class GetERPMtrldefListResponse : LJResponse
     {
         public List<erp_mtrldef> mtrldefList { get; set; }
+        public int pageindex { get; set; }
+        public int pagesize { get; set; }
+        public int totalcnt { get; set; }
     }
 }

+ 5 - 1
JLHHJSvr/Excutor/GetERPMtrldefListExcutor.cs

@@ -112,9 +112,13 @@ namespace JLHHJSvr.Excutor
                     }
                 }
 
-                var resultList = erpHelper.GetERPList<erp_mtrldef>("GetL1Mtrldef", parameters);
+                int total = 0;
+                var resultList = erpHelper.GetERPList<erp_mtrldef>("GetL1Mtrldef", ref total, parameters);
 
                 rslt.mtrldefList = resultList;
+                rslt.totalcnt = total;
+                rslt.pageindex = request.pageindex;
+                rslt.pagesize = request.pagesize;
             }
         }
     }

+ 26 - 0
JLHHJSvr/Helper/ERPHelper.cs

@@ -83,6 +83,32 @@ namespace JLHHJSvr.Helper
                 throw; 
             }
         }
+        public List<T> GetERPList<T>(string apiMethod, ref int total, JObject parameters = null, int tryCnt = 0)
+        {
+            CheckLogin();
+
+            try
+            {
+                var request = BuildRequest(parameters);
+                var result = DoExecute(apiMethod, request);
+
+                if (!_apiResultMap.TryGetValue(apiMethod, out var listKey)) throw new ArgumentException($"Unsupported API Method: {apiMethod}");
+                total = ((int)result["totalcnt"]);
+
+                return result[listKey]?.ToObject<List<T>>() ?? new List<T>();
+            }
+            catch (Exception ex) when (IsTokenExpired(ex))
+            {
+                if (tryCnt >= 3) throw new LJCommonException("超过最大重连次数,请检查连接!");
+
+                Login();
+                return GetERPList<T>(apiMethod, ref total, parameters, tryCnt + 1);
+            }
+            catch
+            {
+                throw;
+            }
+        }
         // 提取请求构建逻辑
         private JObject BuildRequest(JObject parameters)
         {