base_from_coal_inland.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // BaseFromCoalmineInlandIndex 沿海八省动力煤用户供耗存数据指标表
  7. type BaseFromCoalmineInlandIndex struct {
  8. BaseFromCoalmineInlandIndexID int `orm:"column(base_from_coalmine_inland_index_id);pk"`
  9. IndexName string // 省份/企业名称
  10. IndexCode string // 持买单量指标编码
  11. DataTime string // 指标时间
  12. DealValue string // 数据量
  13. GroupName string // 地区
  14. Source string // 来源
  15. Unit string // 来源
  16. Frequency string `description:"频率"`
  17. CreateTime time.Time `description:"插入时间"`
  18. ModifyTime time.Time `description:"修改时间"`
  19. }
  20. //查询指标
  21. func GetBaseFromCoalmineInlandIndex() (items []*BaseFromCoalmineInlandIndex, err error) {
  22. o := orm.NewOrm()
  23. sql := `SELECT * FROM base_from_coalmine_inland_index`
  24. _, err = o.Raw(sql).QueryRows(&items)
  25. return
  26. }
  27. //添加数据
  28. func AddBaseFromCoalInlandIndex(item *BaseFromCoalmineInlandIndex) (lastId int64, err error) {
  29. o := orm.NewOrm()
  30. lastId, err = o.Insert(item)
  31. return
  32. }
  33. func UpdateBaseFromCoalInlandIndex(item *BaseFromCoalmineInlandIndex) (err error) {
  34. o := orm.NewOrm()
  35. sql := `UPDATE base_from_coalmine_inland_index SET deal_value=? WHERE index_name=? AND data_time = ?`
  36. _, err = o.Raw(sql, item.DealValue, item.IndexName, item.DataTime).Exec()
  37. return
  38. }