1234567891011121314151617181920212223242526272829303132333435363738 |
- package services
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/http"
- "hongze/hongze_edb_lib/utils"
- "net/url"
- )
- type EdbDataFromPb struct {
- Date map[string]int64 `json:"date"`
- Ticker map[string]string `json:"ticker"`
- Field map[string]string `json:"field"`
- Value map[string]float64 `json:"value"`
- }
- // GetEdbDataFromPb 获取Pb数据
- func GetEdbDataFromPb(edbCode, startDate, endDate string) (item *EdbDataFromPb, err error) {
- edbCode = url.QueryEscape(edbCode)
- bpUrl := utils.Hz_Pb_Data_Url + `edbInfo/pb?EdbCode=%s&StartDate=%s&EndDate=%s`
- bpUrl = fmt.Sprintf(bpUrl, edbCode, startDate, endDate)
- utils.FileLog.Info("bpUrl:%s", bpUrl)
- body, err := http.Get(bpUrl)
- if err != nil {
- utils.FileLog.Info("GetEdbDataByPb Err:%s", err.Error())
- return
- }
- utils.FileLog.Info("GetEdbDataByPb result:%s", string(body))
- item = new(EdbDataFromPb)
- err = json.Unmarshal(body, &item)
- if err != nil {
- utils.FileLog.Info("GetEdbDataByPb Unmarshal Err:%s", err.Error())
- return
- }
- edbCode, _ = url.QueryUnescape(edbCode)
- return
- }
|