base_from_coal_inland.go 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package models
  2. import (
  3. "eta_gn/eta_index_lib/global"
  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. // BaseFromCoalmineInlandIndex 沿海八省动力煤用户供耗存数据指标表
  21. type BaseFromCoalmineInlandIndex struct {
  22. BaseFromCoalmineInlandIndexID int `gorm:"column:base_from_coalmine_inland_index_id;primaryKey"`
  23. IndexName string `gorm:"column:index_name" description:"省份/企业名称"`
  24. IndexCode string `gorm:"column:index_code" description:"持买单量指标编码"`
  25. DataTime string `gorm:"column:data_time" description:"指标时间"`
  26. DealValue string `gorm:"column:deal_value" description:"数据量"`
  27. GroupName string `gorm:"column:group_name" description:"地区"`
  28. Source string `gorm:"column:source" description:"来源"`
  29. Unit string `gorm:"column:unit" description:"单位"`
  30. Frequency string `gorm:"column:frequency" description:"频率"`
  31. CreateTime time.Time `gorm:"column:create_time" description:"插入时间"`
  32. ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"`
  33. }
  34. func (m *BaseFromCoalmineInlandIndex) TableName() string {
  35. return "base_from_coalmine_inland_index"
  36. }
  37. //查询指标
  38. func GetBaseFromCoalmineInlandIndex() (items []*BaseFromCoalmineInlandIndex, err error) {
  39. //o := orm.NewOrm()
  40. sql := `SELECT * FROM base_from_coalmine_inland_index`
  41. //_, err = o.Raw(sql).QueryRows(&items)
  42. err = global.DEFAULT_DmSQL.Raw(sql).Find(&items).Error
  43. return
  44. }
  45. //添加数据
  46. func AddBaseFromCoalInlandIndex(item *BaseFromCoalmineInlandIndex) (lastId int, err error) {
  47. //o := orm.NewOrm()
  48. //lastId, err = o.Insert(item)
  49. err = global.DEFAULT_DmSQL.Create(item).Error
  50. lastId = item.BaseFromCoalmineInlandIndexID
  51. return
  52. }
  53. func UpdateBaseFromCoalInlandIndex(item *BaseFromCoalmineInlandIndex) (err error) {
  54. //o := orm.NewOrm()
  55. sql := `UPDATE base_from_coalmine_inland_index SET deal_value=? WHERE index_name=? AND data_time = ?`
  56. //_, err = o.Raw(sql, item.DealValue, item.IndexName, item.DataTime).Exec()
  57. err = global.DEFAULT_DmSQL.Exec(sql, item.DealValue, item.IndexName, item.DataTime).Error
  58. return
  59. }