|
@@ -25,12 +25,16 @@ type EdbDataFromThsInterface struct {
|
|
|
} `json:"tables"`
|
|
|
}
|
|
|
|
|
|
-func GetEdbDataFromThs(edbCode, startDate, endDate string) (item *models.EdbDataFromThs, err error) {
|
|
|
- return getEdbDataFromThs(edbCode, startDate, endDate, 0)
|
|
|
+func GetEdbDataFromThs(edbCode, startDate, endDate string) (item models.EdbDataFromThs, err error) {
|
|
|
+ if utils.RunMode == `release` { // 生产环境走官方http请求,测试环境走终端
|
|
|
+ return getEdbDataFromThsHttp(edbCode, startDate, endDate)
|
|
|
+ } else {
|
|
|
+ return getEdbDataFromThsApp(edbCode, startDate, endDate, 0)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// getEdbDataFromThs 获取同花顺接口数据
|
|
|
-func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *models.EdbDataFromThs, err error) {
|
|
|
+func getEdbDataFromThsApp(edbCode, startDate, endDate string, num int) (item models.EdbDataFromThs, err error) {
|
|
|
thsUrl := utils.Hz_Wind_Data_Url + `edbInfo/ths?EdbCode=%s&StartDate=%s&EndDate=%s`
|
|
|
thsUrl = fmt.Sprintf(thsUrl, edbCode, startDate, endDate)
|
|
|
utils.FileLog.Info("thsUrl:" + thsUrl)
|
|
@@ -56,7 +60,7 @@ func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *model
|
|
|
//session has expired,please re-login after using the system
|
|
|
//如果是同花顺登录session失效了,那么就重新请求获取数据
|
|
|
if tmpItems.Errorcode == -1020 && num == 0 {
|
|
|
- return getEdbDataFromThs(edbCode, startDate, endDate, 1)
|
|
|
+ return getEdbDataFromThsApp(edbCode, startDate, endDate, 1)
|
|
|
}
|
|
|
|
|
|
err = errors.New(string(body))
|
|
@@ -102,7 +106,7 @@ func getEdbDataFromThs(edbCode, startDate, endDate string, num int) (item *model
|
|
|
}
|
|
|
tablesList = append(tablesList, tmpTable)
|
|
|
}
|
|
|
- item = &models.EdbDataFromThs{
|
|
|
+ item = models.EdbDataFromThs{
|
|
|
DataVol: tmpItems.DataVol,
|
|
|
Errmsg: tmpItems.Errmsg,
|
|
|
Errorcode: tmpItems.Errorcode,
|
|
@@ -146,8 +150,16 @@ type FutureGoodDataFromThsInterface struct {
|
|
|
} `json:"tables"`
|
|
|
}
|
|
|
|
|
|
-// GetFutureGoodDataFromThs 通过url获取wind的商品数据
|
|
|
-func GetFutureGoodDataFromThs(edbCode, startDate, endDate string, num int) (item *future_good.FutureGoodDataFromThs, err error) {
|
|
|
+func GetFutureGoodDataFromThs(edbCode, startDate, endDate string) (item future_good.FutureGoodDataFromThs, err error) {
|
|
|
+ if utils.RunMode == `release` { // 生产环境走官方http请求,测试环境走终端
|
|
|
+ return getFutureGoodDataFromThsHttp(edbCode, startDate, endDate)
|
|
|
+ } else {
|
|
|
+ return getFutureGoodDataFromThsApp(edbCode, startDate, endDate, 0)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// getFutureGoodDataFromThsApp 通过终端获取wind的商品数据
|
|
|
+func getFutureGoodDataFromThsApp(edbCode, startDate, endDate string, num int) (item future_good.FutureGoodDataFromThs, err error) {
|
|
|
thsUrl := utils.Hz_Wind_Data_Url + `edbInfo/ths/future_good?EdbCode=%s&StartDate=%s&EndDate=%s`
|
|
|
thsUrl = fmt.Sprintf(thsUrl, edbCode, startDate, endDate)
|
|
|
utils.FileLog.Info("thsUrl:" + thsUrl)
|
|
@@ -173,7 +185,7 @@ func GetFutureGoodDataFromThs(edbCode, startDate, endDate string, num int) (item
|
|
|
//session has expired,please re-login after using the system
|
|
|
//如果是同花顺登录session失效了,那么就重新请求获取数据
|
|
|
if tmpItems.Errorcode == -1020 && num == 0 {
|
|
|
- return GetFutureGoodDataFromThs(edbCode, startDate, endDate, 1)
|
|
|
+ return getFutureGoodDataFromThsApp(edbCode, startDate, endDate, 1)
|
|
|
}
|
|
|
|
|
|
err = errors.New(string(body))
|
|
@@ -184,7 +196,7 @@ func GetFutureGoodDataFromThs(edbCode, startDate, endDate string, num int) (item
|
|
|
return
|
|
|
}
|
|
|
table := tmpItems.Tables[0]
|
|
|
- item = &future_good.FutureGoodDataFromThs{
|
|
|
+ item = future_good.FutureGoodDataFromThs{
|
|
|
DataVol: tmpItems.DataVol,
|
|
|
Errmsg: tmpItems.Errmsg,
|
|
|
Errorcode: tmpItems.Errorcode,
|