فهرست منبع

初始化数据

tuoling805 1 سال پیش
والد
کامیت
376b30cbc9
2فایلهای تغییر یافته به همراه56 افزوده شده و 11 حذف شده
  1. 46 0
      models/edb_info.go
  2. 10 11
      services/init_base_index.go

+ 46 - 0
models/edb_info.go

@@ -0,0 +1,46 @@
+package models
+
+import "time"
+
+type EdbInfoResp struct {
+	Ret     int    `json:"Ret"`
+	Msg     string `json:"Msg"`
+	ErrMsg  string `json:"ErrMsg"`
+	ErrCode string `json:"ErrCode"`
+	Data    struct {
+		EdbInfoId        int       `json:"EdbInfoId"`
+		SourceName       string    `json:"SourceName"`
+		Source           int       `json:"Source"`
+		EdbCode          string    `json:"EdbCode"`
+		EdbName          string    `json:"EdbName"`
+		EdbNameSource    string    `json:"EdbNameSource"`
+		Frequency        string    `json:"Frequency"`
+		Unit             string    `json:"Unit"`
+		StartDate        string    `json:"StartDate"`
+		EndDate          string    `json:"EndDate"`
+		ClassifyId       int       `json:"ClassifyId"`
+		SysUserId        int       `json:"SysUserId"`
+		SysUserRealName  string    `json:"SysUserRealName"`
+		UniqueCode       string    `json:"UniqueCode"`
+		CreateTime       time.Time `json:"CreateTime"`
+		ModifyTime       time.Time `json:"ModifyTime"`
+		MinValue         int       `json:"MinValue"`
+		MaxValue         int       `json:"MaxValue"`
+		CalculateFormula string    `json:"CalculateFormula"`
+		EdbType          int       `json:"EdbType"`
+		Sort             int       `json:"Sort"`
+		MoveType         int       `json:"MoveType"`
+		MoveFrequency    string    `json:"MoveFrequency"`
+		NoUpdate         int       `json:"NoUpdate"`
+		ServerUrl        string    `json:"ServerUrl"`
+		EdbInfoType      int       `json:"EdbInfoType"`
+		EdbNameEn        string    `json:"EdbNameEn"`
+		UnitEn           string    `json:"UnitEn"`
+		LatestDate       string    `json:"LatestDate"`
+		LatestValue      int       `json:"LatestValue"`
+		ChartImage       string    `json:"ChartImage"`
+		Calendar         string    `json:"Calendar"`
+		DataDateType     string    `json:"DataDateType"`
+	} `json:"Data"`
+	Success bool `json:"Success"`
+}

+ 10 - 11
services/init_base_index.go

@@ -164,7 +164,7 @@ func InitBaseIndexData() {
 					return
 				}
 
-				indexResp := new(models.BaseResponse)
+				indexResp := new(models.EdbInfoResp)
 				err = json.Unmarshal(result, &indexResp)
 				if err != nil {
 					utils.FileLog.Info("初始化分类2失败:" + err.Error())
@@ -182,16 +182,15 @@ func InitBaseIndexData() {
 				}
 				fmt.Println("add index success:" + indexCode)
 
-				////刷新指标
-				//var method string
-				//if source == "wind" {
-				//	method = "wind/refresh"
-				//}
-				//refreshMap := make(map[string]interface{})
-				//refreshMap["EdbInfoId"] = ""
-				//refreshMap["EdbCode"] = indexCode
-				//refreshMap["StartDate"] = "1990-01-01"
-
+				//刷新指标
+				if source == "wind" {
+					method = "wind/refresh"
+				}
+				refreshMap := make(map[string]interface{})
+				refreshMap["EdbInfoId"] = indexResp.Data.EdbInfoId
+				refreshMap["EdbCode"] = indexCode
+				refreshMap["StartDate"] = "1990-01-01"
+				PostEdbLib(refreshMap, method)
 			} else {
 				fmt.Println("data is empty")
 				fmt.Println(classifyFirst, classifySecond, classifyThree, indexCode, indexName, frequency, unit, source)