base_from_wind.go 828 B

1234567891011121314151617181920212223242526272829303132
  1. package services
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/http"
  6. "hongze/hongze_edb_lib/utils"
  7. )
  8. type EdbDataFromWind struct {
  9. Close map[string]float64 `json:"CLOSE"`
  10. Dt map[string]int64 `json:"DT"`
  11. ErrMsg string
  12. }
  13. // GetEdbDataFromWind 获取wind数据
  14. func GetEdbDataFromWind(edbCode, startDate, endDate string) (item *EdbDataFromWind, err error) {
  15. thsUrl := utils.Hz_Wind_Data_Url + `edbInfo/wind?EdbCode=%s&StartDate=%s&EndDate=%s`
  16. thsUrl = fmt.Sprintf(thsUrl, edbCode, startDate, endDate)
  17. utils.FileLog.Info("thsUrl:%s", thsUrl)
  18. body, err := http.Get(thsUrl)
  19. fmt.Println("GetEdbDataByThs body:")
  20. fmt.Println(string(body))
  21. utils.FileLog.Info("wind result:", string(body))
  22. if err != nil {
  23. return
  24. }
  25. item = new(EdbDataFromWind)
  26. err = json.Unmarshal(body, &item)
  27. return
  28. }