Browse Source

feat:优化同花顺数据获取

Roc 1 year ago
parent
commit
5bab131910
1 changed files with 8 additions and 2 deletions
  1. 8 2
      services/base_from_ths_http.go

+ 8 - 2
services/base_from_ths_http.go

@@ -31,6 +31,9 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
 	}
 
 	body, err, _ := postCurl(thsUrl, dataMap, 0)
+	if err != nil {
+		return
+	}
 
 	tmpItems := new(EdbDataFromThsInterface)
 	err = json.Unmarshal(body, &tmpItems)
@@ -111,6 +114,9 @@ func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item Futu
 	}
 
 	body, err, _ := postCurl(thsUrl, dataMap, 0)
+	if err != nil {
+		return
+	}
 
 	tmpItems := new(FutureGoodDataFromThsInterface)
 	err = json.Unmarshal(body, &tmpItems)
@@ -211,8 +217,8 @@ func postCurl(urlStr string, dataMap map[string]interface{}, num int) (body []by
 		}
 		num++
 		return postCurl(urlStr, dataMap, num)
-	} else if response.ErrorCode != 1 {
-		utils.FileLog.Info(fmt.Sprint("post data err", ";url:", urlStr, ";params:", reqStr, ";response:", string(body)))
+	} else if response.ErrorCode != 0 {
+		utils.FileLog.Info(fmt.Sprint("post data err:", response.ErrMsg, ";url:", urlStr, ";params:", reqStr, ";response:", string(body)))
 		err = errors.New(response.ErrMsg)
 		return
 	}