|
@@ -0,0 +1,41 @@
|
|
|
+package services
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_cygx/models"
|
|
|
+ "io/ioutil"
|
|
|
+ "net/http"
|
|
|
+)
|
|
|
+
|
|
|
+func GetCom() {
|
|
|
+ getUrl := "https://vmp.hzinsights.com/v2api/articles/stock"
|
|
|
+ result, err := http.Get(getUrl)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer result.Body.Close()
|
|
|
+ body, err := ioutil.ReadAll(result.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("err:" + err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(body)
|
|
|
+ var resp models.VmpStocks
|
|
|
+ err = json.Unmarshal(body, &resp)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("获取上市公司信息失败 Err:%s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ items := make([]*models.CygxYanxuanSpecialCompany, 0)
|
|
|
+ for _, v := range resp.Data {
|
|
|
+ items = append(items, &v)
|
|
|
+ }
|
|
|
+
|
|
|
+ err = models.AddCygxYanxuanSpecialCompanyMulti(items)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("AddCygxYanxuanSpecialCompanyMulti Err:%s", err.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+}
|