askserie_video_collect.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxAskserieVideoCollect 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. }
  20. // 添加
  21. func AddCygxAskserieVideoCollect(item *CygxAskserieVideoCollect) (err error) {
  22. o := orm.NewOrm()
  23. _, err = o.Insert(item)
  24. return
  25. }
  26. func RemoveAskserieVideoCollect(userId, askserieVideoId int) (err error) {
  27. o := orm.NewOrm()
  28. sql := `DELETE FROM cygx_askserie_video_collect WHERE user_id=? AND askserie_video_id=? `
  29. _, err = o.Raw(sql, userId, askserieVideoId).Exec()
  30. return
  31. }
  32. func GetAskserieVideoCount(userId, askserieVideoId int) (count int, err error) {
  33. sql := `SELECT COUNT(1) AS count FROM cygx_askserie_video_collect WHERE user_id=? AND askserie_video_id=? `
  34. err = orm.NewOrm().Raw(sql, userId, askserieVideoId).QueryRow(&count)
  35. return
  36. }
  37. func GetUserCygxAskserieVideoCollectList(userId int) (items []*CygxAskserieVideoCollect, err error) {
  38. sql := `SELECT a.* FROM cygx_askserie_video_collect AS a
  39. WHERE a.user_id=?
  40. ORDER BY a.id DESC `
  41. _, err = orm.NewOrm().Raw(sql, userId).QueryRows(&items)
  42. return
  43. }