package models import ( "github.com/beego/beego/v2/client/orm" "time" ) type CygxMinutesSummaryVoiceHistory struct { Id int `orm:"column(id);pk"` ArticleId int `description:"文章ID"` UserId int `description:"用户ID"` CreateTime time.Time `description:"创建时间"` Mobile string `description:"手机号"` Email string `description:"邮箱"` CompanyId int `description:"公司id"` CompanyName string `description:"公司名称"` RealName string `description:"用户实际名称"` SellerName string `description:"所属销售"` PlaySeconds string `description:"播放时间 单位s"` ModifyTime time.Time `description:"视频修改时间"` RegisterPlatform int `description:"来源 1小程序,2:网页"` } // 添加 func AddCygxMinutesSummaryVoiceHistory(item *CygxMinutesSummaryVoiceHistory) (err error) { o := orm.NewOrm() _, err = o.Insert(item) return } func GetLastCygxMinutesSummaryVoiceHistory(articleId, userId int) (item *CygxMinutesSummaryVoiceHistory, err error) { o := orm.NewOrm() sql := ` SELECT * FROM cygx_minutes_summary_voice_history WHERE article_id=? AND user_id=? ORDER BY create_time DESC limit 1 ` err = o.Raw(sql, articleId, userId).QueryRow(&item) return } func UpdateLastCygxMinutesSummaryVoiceHistory(playSeconds string, lastId int) (err error) { o := orm.NewOrm() sql := ` UPDATE cygx_minutes_summary_voice_history SET play_seconds =? WHERE id=? ` _, err = o.Raw(sql, playSeconds, lastId).Exec() return }