|
@@ -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)
|
|
|
{
|