askserie_video_history_record.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxAskserieVideoHistoryRecord struct {
  7. Id int `orm:"column(id);pk"`
  8. AskserieVideoId int `description:"askserie_video_id"`
  9. UserId int `description:"用户ID"`
  10. CreateTime time.Time `description:"创建时间"`
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. RealName string `description:"用户实际名称"`
  16. SellerName string `description:"所属销售"`
  17. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  18. ModifyTime time.Time `description:"更新时间"`
  19. VideoDuration int `description:"播放时长"`
  20. }
  21. // 添加
  22. func AddCygxAskserieVideoHistoryRecord(item *CygxAskserieVideoHistoryRecord) (err error) {
  23. o := orm.NewOrm()
  24. _, err = o.Insert(item)
  25. return
  26. }
  27. func UpdateAskserieVideoCounts(askserieVideoId int) (err error) {
  28. sql := `UPDATE cygx_askserie_video SET video_counts = video_counts+1 WHERE askserie_video_id = ? `
  29. o := orm.NewOrm()
  30. _, err = o.Raw(sql, askserieVideoId).Exec()
  31. return
  32. }
  33. func GetLastCygxAskserieVideoHistoryRecord(activityId, userId int) (item *CygxActivityVoiceHistory, err error) {
  34. o := orm.NewOrm()
  35. sql := ` SELECT * FROM cygx_askserie_video_history_record WHERE askserie_video_id=? AND user_id=? AND register_platform = 1 ORDER BY create_time DESC limit 1 `
  36. err = o.Raw(sql, activityId, userId).QueryRow(&item)
  37. return
  38. }
  39. func UpdateLastCygxAskserieVideoHistoryRecord(playSeconds string, lastId int) (err error) {
  40. o := orm.NewOrm()
  41. sql := ` UPDATE cygx_askserie_video_history_record SET video_duration = video_duration+? WHERE id=? `
  42. _, err = o.Raw(sql, playSeconds, lastId).Exec()
  43. return
  44. }