variety_edb_info.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package supply_analysis
  2. import (
  3. "eta_gn/eta_index_lib/global"
  4. "time"
  5. )
  6. // VarietyEdbInfo variety_edb_info 品种指标表
  7. type VarietyEdbInfo struct {
  8. VarietyEdbId int `gorm:"primaryKey;autoIncrement;column:variety_edb_id" description:"品种指标ID"`
  9. VarietyId int `gorm:"column:variety_id" description:"品种id"`
  10. EdbName string `gorm:"column:edb_name" description:"品种指标名称"`
  11. Frequency string `gorm:"column:frequency" description:"频度"`
  12. StartDate time.Time `gorm:"column:start_date" description:"开始日期"`
  13. EndDate time.Time `gorm:"column:end_date" description:"结束日期"`
  14. LatestValue float64 `gorm:"column:latest_value" description:"最新值"`
  15. EdbInfoId int `gorm:"column:edb_info_id" description:"指标id"`
  16. EdbCode string `gorm:"column:edb_code" description:"品种编码"`
  17. Source int `gorm:"column:source" description:"来源,1:影响周度产量;2:周度产量变动;3:影响月度产量;4:月度产量变动"`
  18. ModifyTime time.Time `gorm:"column:modify_time" description:"更新时间"`
  19. CreateTime time.Time `gorm:"column:create_time" description:"添加时间"`
  20. }
  21. // GetAllVarietyEdbInfoByVarietyId 根据品种id获取所有的指标
  22. func GetAllVarietyEdbInfoByVarietyId(varietyId int) (items []*VarietyEdbInfo, err error) {
  23. sql := `SELECT * FROM variety_edb_info AS a WHERE a.variety_id = ? ORDER BY a.variety_edb_id ASC `
  24. err = global.DEFAULT_DmSQL.Raw(sql, varietyId).Scan(&items).Error
  25. return
  26. }
  27. // GetVarietyEdbInfoByEdbInfoId 根据ETA指标库中的指标id获取指标
  28. func GetVarietyEdbInfoByEdbInfoId(varietyId int) (item *VarietyEdbInfo, err error) {
  29. sql := `SELECT * FROM variety_edb_info AS a WHERE a.edb_info_id = ? ORDER BY a.variety_edb_id ASC `
  30. err = global.DEFAULT_DmSQL.Raw(sql, varietyId).First(&item).Error
  31. return
  32. }