cygx_yanxuan_special_record.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. type CygxYanxuanSpecialRecordResp struct {
  22. CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
  23. UserId int // 用户ID
  24. Mobile string // 手机号
  25. Email string // 邮箱
  26. CompanyId int // 公司ID
  27. CompanyName string // 公司名称
  28. RealName string // 用户实际名称
  29. SellerName string // 所属销售
  30. CreateTime string // 创建时间
  31. ModifyTime time.Time // 修改时间
  32. RegisterPlatform int // 来源 1小程序,2:网页
  33. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  34. StopTime int // 停留时间
  35. }
  36. func AddCygxYanxuanSpecialRecord(item *CygxYanxuanSpecialRecord) (lastId int64, err error) {
  37. o := orm.NewOrm()
  38. lastId, err = o.Insert(item)
  39. return
  40. }
  41. type AddCygxYanxuanSpecialRecordReq struct {
  42. SpecialId int `description:"专栏文章id"`
  43. StopTime int `description:"停留时间"`
  44. }
  45. // 获取数量
  46. func GetCygxYanxuanSpecialRecordCount(condition string, pars []interface{}) (count int, err error) {
  47. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as art WHERE 1= 1 `
  48. if condition != "" {
  49. sqlCount += condition
  50. }
  51. o := orm.NewOrm()
  52. err = o.Raw(sqlCount, pars).QueryRow(&count)
  53. return
  54. }
  55. // 判断一个用户是否阅读过 某一篇研选专栏
  56. func GetCygxYanxuanSpecialRecordCountByUser(userId, yanxuanSpecialId int) (count int, err error) {
  57. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as a WHERE user_id= ? AND yanxuan_special_id = ? `
  58. o := orm.NewOrm()
  59. err = o.Raw(sqlCount, userId, yanxuanSpecialId).QueryRow(&count)
  60. return
  61. }
  62. // 详细日志记录,不过滤时长小于 3 秒的那种
  63. type CygxYanxuanSpecialRecordLog struct {
  64. CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
  65. UserId int // 用户ID
  66. Mobile string // 手机号
  67. Email string // 邮箱
  68. CompanyId int // 公司ID
  69. CompanyName string // 公司名称
  70. RealName string // 用户实际名称
  71. SellerName string // 所属销售
  72. CreateTime time.Time // 创建时间
  73. ModifyTime time.Time // 修改时间
  74. RegisterPlatform int // 来源 1小程序,2:网页
  75. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  76. StopTime int // 停留时间
  77. }
  78. func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {
  79. o := orm.NewOrm()
  80. lastId, err = o.Insert(item)
  81. return
  82. }
  83. // 列表
  84. func GetCygxYanxuanSpecialRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialRecordResp, err error) {
  85. o := orm.NewOrm()
  86. sql := `SELECT * FROM cygx_yanxuan_special_record as art WHERE 1= 1 `
  87. if condition != "" {
  88. sql += condition
  89. }
  90. sql += ` LIMIT ?,? `
  91. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  92. return
  93. }