package models import ( "eta_gn/eta_index_lib/global" "time" ) // BaseFromCoalmineCoastalIndex 沿海八省动力煤用户供耗存数据指标表 //type BaseFromCoalmineCoastalIndex struct { // BaseFromCoalmineCoastalIndexID int `orm:"column(base_from_coalmine_coastal_index_id);pk"` // IndexName string // 省份/企业名称 // IndexCode string // 持买单量指标编码 // DataTime string // 指标时间 // DealValue string // 数据量 // GroupName string // 地区 // Source string // 来源 // Unit string //单位 // Frequency string `description:"频率"` // CreateTime time.Time `description:"插入时间"` // ModifyTime time.Time `description:"修改时间"` //} // BaseFromCoalmineCoastalIndex 沿海八省动力煤用户供耗存数据指标表 type BaseFromCoalmineCoastalIndex struct { BaseFromCoalmineCoastalIndexID int `gorm:"column:base_from_coalmine_coastal_index_id;primaryKey"` IndexName string `gorm:"column:index_name"` // 省份/企业名称 IndexCode string `gorm:"column:index_code"` // 持买单量指标编码 DataTime string `gorm:"column:data_time"` // 指标时间 DealValue string `gorm:"column:deal_value"` // 数据量 GroupName string `gorm:"column:group_name"` // 地区 Source string `gorm:"column:source"` // 来源 Unit string `gorm:"column:unit"` // 单位 Frequency string `gorm:"column:frequency" description:"频率"` CreateTime time.Time `gorm:"column:create_time" description:"插入时间"` ModifyTime time.Time `gorm:"column:modify_time" description:"修改时间"` } func (m *BaseFromCoalmineCoastalIndex) TableName() string { return "base_from_coalmine_coastal_index" } // 查询指标 func GetBaseFromCoalmineCoastalIndex() (items []*BaseFromCoalmineCoastalIndex, err error) { //o := orm.NewOrm() sql := `SELECT * FROM base_from_coalmine_coastal_index` //_, err = o.Raw(sql).QueryRows(&items) err = global.DEFAULT_DmSQL.Raw(sql).Find(&items).Error return } // 添加数据 func AddBaseFromCoalCoastalIndex(item *BaseFromCoalmineCoastalIndex) (lastId int, err error) { //o := orm.NewOrm() //lastId, err = o.Insert(item) err = global.DEFAULT_DmSQL.Create(item).Error lastId = item.BaseFromCoalmineCoastalIndexID return } func UpdateBaseFromCoalCoastalIndex(item *BaseFromCoalmineCoastalIndex) (err error) { //o := orm.NewOrm() sql := `UPDATE base_from_coalmine_coastal_index SET deal_value=? WHERE index_name=? AND data_time = ?` //_, err = o.Raw(sql, item.DealValue, item.IndexName, item.DataTime).Exec() err = global.DEFAULT_DmSQL.Exec(sql, item.DealValue, item.IndexName, item.DataTime).Error return }