package models import ( "hongze/mysteel_watch/global" "time" "context" ) type EdbInfo struct { EdbInfoId int `orm:"column(edb_info_id);pk"` SourceName string `description:"来源名称"` Source int `description:"来源id"` EdbCode string `description:"指标编码"` EdbName string `description:"指标名称"` EdbNameSource string `description:"指标名称来源"` Frequency string `description:"频率"` Unit string `description:"单位"` StartDate string `description:"起始日期"` EndDate string `description:"终止日期"` ClassifyId int `description:"分类id"` SysUserId int SysUserRealName string UniqueCode string `description:"指标唯一编码"` CreateTime time.Time ModifyTime time.Time MinValue float64 `description:"指标最小值"` MaxValue float64 `description:"指标最大值"` CalculateFormula string `description:"计算公式"` EdbType int `description:"指标类型:1:基础指标,2:计算指标"` Sort int `description:"排序字段"` MoveType int `description:"移动方式:1:领先(默认),2:滞后"` MoveFrequency string `description:"移动频度"` NoUpdate int8 `description:"是否停止更新,0:继续更新;1:停止更新"` ServerUrl string `description:"服务器地址"` EdbInfoType int `description:"指标类型,0:普通指标,1:预测指标"` EdbNameEn string `description:"英文指标名称"` UnitEn string `description:"英文单位"` LatestDate string `description:"数据最新日期"` LatestValue float64 `description:"数据最新值"` ChartImage string `description:"图表图片"` } func (d *EdbInfo) GetEdbInfoItem(runMod, indexCode string) (item *EdbInfo, err error) { if runMod == "release" { err = global.MYSQL["hzdata"].WithContext(context.TODO()).Table("edb_info"). Where("edb_code = ?", indexCode).First(&item).Error return } else { err = global.DEFAULT_MYSQL.WithContext(context.TODO()).Table("edb_info"). Where("edb_code = ?", indexCode).First(&item).Error return } } type EdbDataMysteelChemical struct { EdbDataId int `orm:"column(edb_data_id);pk"` EdbInfoId int EdbCode string DataTime string Value string CreateTime time.Time ModifyTime time.Time DataTimestamp int64 } func (d *EdbDataMysteelChemical) GetEdbInfoDataList(runMod string, indexCode string) (item []*EdbDataMysteelChemical, err error) { if runMod == "release" { err = global.MYSQL["hzdata"].WithContext(context.TODO()).Model(d). Where("index_code = ?", indexCode).Find(&item).Error return } else { err = global.DEFAULT_MYSQL.WithContext(context.TODO()).Model(d). Where("index_code = ?", indexCode).Find(&item).Error return } } // 新增 func (r *EdbDataMysteelChemical) Add(runMod string, list []EdbDataMysteelChemical) (err error) { if runMod == "release" { err = global.MYSQL["hzdata"].Create(list).Error return } else { err = global.DEFAULT_MYSQL.Create(list).Error return } } // 修改 func (r *EdbDataMysteelChemical) Update(runMod string, updateCols []string) (err error) { if runMod == "release" { err = global.MYSQL["hzdata"].Model(r).Where("edb_data_id=?", r.EdbDataId).Select(updateCols).Updates(r).Error return } else { err = global.DEFAULT_MYSQL.Model(r).Where("edb_data_id=?", r.EdbDataId).Select(updateCols).Updates(r).Error return } }