cygx_yanxuan_special_record.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxYanxuanSpecialRecord struct {
  7. CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
  8. UserId int // 用户ID
  9. Mobile string // 手机号
  10. Email string // 邮箱
  11. CompanyId int // 公司ID
  12. CompanyName string // 公司名称
  13. RealName string // 用户实际名称
  14. SellerName string // 所属销售
  15. CreateTime time.Time // 创建时间
  16. ModifyTime time.Time // 修改时间
  17. RegisterPlatform int // 来源 1小程序,2:网页
  18. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  19. StopTime int // 停留时间
  20. }
  21. func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
  22. o := orm.NewOrm()
  23. lastId, err = o.Insert(item)
  24. return
  25. }
  26. type AddCygxYanxuanSpecialRecordReq struct {
  27. SpecialId int `description:"专栏文章id"`
  28. StopTime int `description:"停留时间"`
  29. }
  30. // 获取数量
  31. func GetCygxYanxuanSpecialRecordCount(condition string, pars []interface{}) (count int, err error) {
  32. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as a WHERE 1= 1 `
  33. if condition != "" {
  34. sqlCount += condition
  35. }
  36. o := orm.NewOrm()
  37. err = o.Raw(sqlCount, pars).QueryRow(&count)
  38. return
  39. }
  40. // 判断一个用户是否阅读过 某一篇研选专栏
  41. func GetCygxYanxuanSpecialRecordCountByUser(userId, yanxuanSpecialId int) (count int, err error) {
  42. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as a WHERE user_id= ? AND yanxuan_special_id = ? `
  43. o := orm.NewOrm()
  44. err = o.Raw(sqlCount, userId, yanxuanSpecialId).QueryRow(&count)
  45. return
  46. }
  47. // 详细日志记录,不过滤时长小于 3 秒的那种
  48. type CygxYanxuanSpecialRecordLog struct {
  49. CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
  50. UserId int // 用户ID
  51. Mobile string // 手机号
  52. Email string // 邮箱
  53. CompanyId int // 公司ID
  54. CompanyName string // 公司名称
  55. RealName string // 用户实际名称
  56. SellerName string // 所属销售
  57. CreateTime time.Time // 创建时间
  58. ModifyTime time.Time // 修改时间
  59. RegisterPlatform int // 来源 1小程序,2:网页
  60. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  61. StopTime int // 停留时间
  62. }
  63. func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {
  64. o := orm.NewOrm()
  65. lastId, err = o.Insert(item)
  66. return
  67. }