package models import ( "github.com/beego/beego/v2/client/orm" "time" ) // BaseFromCoalmineFirmIndex 煤矿产量周度公司数据表 type BaseFromCoalmineFirmIndex struct { BaseFromCoalmineFirmIndexID int `orm:"column(base_from_coalmine_firm_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:"修改时间"` } //查询指标 func GetBaseFromCoalmineFirmIndex() (items []*BaseFromCoalmineFirmIndex, err error) { o := orm.NewOrmUsingDB("data") sql := `SELECT * FROM base_from_coalmine_firm_index` _, err = o.Raw(sql).QueryRows(&items) return } //添加数据 func AddBaseFromCoalFirmIndex(item *BaseFromCoalmineFirmIndex) (lastId int64, err error) { o := orm.NewOrmUsingDB("data") lastId, err = o.Insert(item) return } func UpdateBaseFromCoalFirmIndex(item *BaseFromCoalmineFirmIndex) (err error) { o := orm.NewOrmUsingDB("data") sql := `UPDATE base_from_coalmine_firm_index SET deal_value=? WHERE index_name=? AND data_time = ?` _, err = o.Raw(sql, item.DealValue, item.IndexName, item.DataTime).Exec() return }