Roc 1 жил өмнө
parent
commit
0a48124256

+ 2 - 2
models/base_from_ths.go

@@ -25,7 +25,7 @@ type Tables struct {
 }
 
 // 新增同花顺指标数据
-func AddEdbDataFromThs(edbCode string, item *EdbDataFromThs) (err error) {
+func AddEdbDataFromThs(edbCode string, item EdbDataFromThs) (err error) {
 	o := orm.NewOrm()
 
 	if len(item.Tables) > 0 {
@@ -61,7 +61,7 @@ func AddEdbDataFromThs(edbCode string, item *EdbDataFromThs) (err error) {
 }
 
 // 刷新同花顺指标数据
-func RefreshEdbDataFromThs(edbInfoId int, edbCode, startDate string, item *EdbDataFromThs) (err error) {
+func RefreshEdbDataFromThs(edbInfoId int, edbCode, startDate string, item EdbDataFromThs) (err error) {
 	o := orm.NewOrm()
 	source := utils.DATA_SOURCE_THS
 

+ 2 - 2
models/future_good/future_good_edb_data.go

@@ -85,7 +85,7 @@ func GetFutureGoodEdbDataList(condition string, pars []interface{}) (list []*Fut
 }
 
 // AddEdbDataFromWind 添加wind商品指标数据
-func AddEdbDataFromWind(futureGoodEdbInfoId int, edbCode string, item *FutureGoodDataFromThs) (err error) {
+func AddEdbDataFromWind(futureGoodEdbInfoId int, edbCode string, item FutureGoodDataFromThs) (err error) {
 	o := orm.NewOrm()
 
 	var isAdd bool
@@ -135,7 +135,7 @@ type RefreshFutureEdbEdbInfoReq struct {
 }
 
 // RefreshFutureGoodEdbDataFromThs 刷新wind期货指标数据
-func RefreshFutureGoodEdbDataFromThs(futureGoodEdbInfoId int, edbCode, startDate string, item *FutureGoodDataFromThs) (err error) {
+func RefreshFutureGoodEdbDataFromThs(futureGoodEdbInfoId int, edbCode, startDate string, item FutureGoodDataFromThs) (err error) {
 	o := orm.NewOrm()
 	to, err := o.Begin()
 	if err != nil {

+ 9 - 7
services/base_from_ths_http.go

@@ -5,6 +5,8 @@ import (
 	"errors"
 	"fmt"
 	"github.com/shopspring/decimal"
+	"hongze/hongze_edb_lib/models"
+	"hongze/hongze_edb_lib/models/future_good"
 	"hongze/hongze_edb_lib/services/alarm_msg"
 	"hongze/hongze_edb_lib/utils"
 	"io"
@@ -18,7 +20,7 @@ import (
 var refreshToken = `eyJzaWduX3RpbWUiOiIyMDIzLTAzLTI0IDEzOjQ3OjExIn0=.eyJ1aWQiOiI1NzY2NDgxMDkifQ==.339B8D21168AC21A0F80840544E38378AB2D04A02D325F0CD1C44251915233F6`
 var tokenRedisKey = `THS_SERVER_ACCESS_TOKEN`
 
-func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFromThs, err error) {
+func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item models.EdbDataFromThs, err error) {
 	thsUrl := `https://quantapi.51ifind.com/api/v1/edb_service`
 	//indicators 是 半角逗号分隔的所有指标,宏观指标过多,推荐使用Windows超级命令生成。 "indicators":"M001620326,M002822183"
 	//functionpara 否 key-value格式,省略时不进行更新时间筛选。两个时间控件更新起始时间(startrtime)和更新结束时间(endrtime),不勾选时省略见下方代码块
@@ -47,7 +49,7 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
 		return
 	}
 	// 因为table里面的value有的时候返回的是string,有的是float64,所以需要用interface来反射取值
-	tablesList := make([]Tables, 0)
+	tablesList := make([]models.Tables, 0)
 	for _, table := range tmpItems.Tables {
 		tableIdList := make([]string, 0)
 		tableTimeList := make([]string, 0)
@@ -78,14 +80,14 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
 			}
 			tableValueList = append(tableValueList, tableValue)
 		}
-		tmpTable := Tables{
+		tmpTable := models.Tables{
 			ID:    tableIdList,
 			Time:  tableTimeList,
 			Value: tableValueList,
 		}
 		tablesList = append(tablesList, tmpTable)
 	}
-	item = EdbDataFromThs{
+	item = models.EdbDataFromThs{
 		DataVol:   tmpItems.DataVol,
 		Errmsg:    tmpItems.Errmsg,
 		Errorcode: tmpItems.Errorcode,
@@ -96,7 +98,7 @@ func GetEdbDataFromThsHttp(edbCode, startDate, endDate string) (item EdbDataFrom
 }
 
 // GetFutureGoodDataFromThsHttp 通过url获取同花顺的商品数据
-func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item FutureGoodDataFromThs, err error) {
+func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item future_good.FutureGoodDataFromThs, err error) {
 	thsUrl := `https://quantapi.51ifind.com/api/v1/cmd_history_quotation`
 
 	//codes 是 半角逗号分隔的所有代码 "codes":"300033.SZ,600030.SH"
@@ -133,12 +135,12 @@ func GetFutureGoodDataFromThsHttp(edbCode, startDate, endDate string) (item Futu
 		return
 	}
 	table := tmpItems.Tables[0]
-	item = FutureGoodDataFromThs{
+	item = future_good.FutureGoodDataFromThs{
 		DataVol:   tmpItems.DataVol,
 		Errmsg:    tmpItems.Errmsg,
 		Errorcode: tmpItems.Errorcode,
 		Perf:      tmpItems.Perf,
-		Tables: FutureGoodDataTables{
+		Tables: future_good.FutureGoodDataTables{
 			Time:       table.Time,
 			Open:       table.Table.Open,
 			High:       table.Table.High,