|
@@ -0,0 +1,57 @@
|
|
|
+package models
|
|
|
+
|
|
|
+import (
|
|
|
+ "eta/eta_index_lib/global"
|
|
|
+ "eta/eta_index_lib/utils"
|
|
|
+ "fmt"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+type EdbRefreshApiRecord struct {
|
|
|
+ EdbRefreshApiRecordId int `gorm:"column:edb_refresh_api_record_id;type:int(10) UNSIGNED;primaryKey;not null;" json:"edb_refresh_api_record_id"`
|
|
|
+ EdbCode string `gorm:"column:edb_code;type:varchar(255);comment:指标编码;" json:"edb_code"` // 指标编码
|
|
|
+ EdbName string `gorm:"column:edb_name;type:varchar(255);comment:指标名称;" json:"edb_name"` // 指标名称
|
|
|
+ Source int `gorm:"column:source;type:int(9) UNSIGNED;comment:指标来源;default:0;" json:"source"` // 指标来源
|
|
|
+ Frequency string `gorm:"column:frequency;type:varchar(32);comment:指标频度;" json:"frequency"` // 指标频度
|
|
|
+ StartDate string `gorm:"column:start_date;type:varchar(64);comment:刷新开始时间;" json:"start_date"` // 刷新开始时间
|
|
|
+ Result int `gorm:"column:result;type:tinyint(4) UNSIGNED;comment:刷新成功与否,0:未成功,1:已成功;default:0;" json:"result"` // 刷新成功与否,0:未成功,1:已成功
|
|
|
+ RefreshDesc string `gorm:"column:refresh_desc;type:text;comment:刷新的备注;" json:"refresh_desc"` // 刷新的备注
|
|
|
+ RefreshNum int `gorm:"column:refresh_num;type:int(9) UNSIGNED;comment:刷新到了的数据数量;default:0;" json:"refresh_num"` // 刷新到了的数据数量
|
|
|
+ CreateTime time.Time `gorm:"column:create_time;type:datetime;comment:刷新时间;default:NULL;" json:"create_time"` // 刷新时间
|
|
|
+}
|
|
|
+
|
|
|
+func (m *EdbRefreshApiRecord) Add() (err error) {
|
|
|
+ err = global.DEFAULT_DB.Create(m).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func AddEdbRefreshApiRecordByRefresh(edbInfo *EdbInfo, startDate string, num int, resultErr error) {
|
|
|
+ var err error
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ utils.FileLog.Info(fmt.Sprintf("AddEdbRefreshApiRecordByRefresh, err: %v", err))
|
|
|
+ }
|
|
|
+ }()
|
|
|
+ result := 1
|
|
|
+ resultErrMsg := ``
|
|
|
+ if resultErr != nil {
|
|
|
+ result = 0
|
|
|
+ resultErrMsg = resultErr.Error()
|
|
|
+ }
|
|
|
+ record := &EdbRefreshApiRecord{
|
|
|
+ EdbRefreshApiRecordId: 0,
|
|
|
+ EdbCode: edbInfo.EdbCode,
|
|
|
+ EdbName: edbInfo.EdbName,
|
|
|
+ Source: edbInfo.Source,
|
|
|
+ Frequency: edbInfo.Frequency,
|
|
|
+ StartDate: startDate,
|
|
|
+ Result: result,
|
|
|
+ RefreshDesc: resultErrMsg,
|
|
|
+ RefreshNum: num,
|
|
|
+ CreateTime: time.Now(),
|
|
|
+ }
|
|
|
+ err = global.DEFAULT_DB.Create(record).Error
|
|
|
+
|
|
|
+ return
|
|
|
+}
|