base_from_coal_firm.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // BaseFromCoalmineFirmIndex 煤矿产量周度公司数据表
  7. type BaseFromCoalmineFirmIndex struct {
  8. BaseFromCoalmineFirmIndexID int `orm:"column(base_from_coalmine_firm_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 GetBaseFromCoalmineFirmIndex() (items []*BaseFromCoalmineFirmIndex, err error) {
  22. o := orm.NewOrm()
  23. sql := `SELECT * FROM base_from_coalmine_firm_index`
  24. _, err = o.Raw(sql).QueryRows(&items)
  25. return
  26. }
  27. // 添加数据
  28. func AddBaseFromCoalFirmIndex(item *BaseFromCoalmineFirmIndex) (lastId int64, err error) {
  29. o := orm.NewOrm()
  30. lastId, err = o.Insert(item)
  31. return
  32. }
  33. func UpdateBaseFromCoalFirmIndex(item *BaseFromCoalmineFirmIndex) (err error) {
  34. o := orm.NewOrm()
  35. sql := `UPDATE base_from_coalmine_firm_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. }