cygx_yanxuan_special_record.go 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 GetCygxYanxuanSpecialRecordCountGroup(condition string, pars []interface{}) (count int, err error) {
  57. sqlCount := ` SELECT count(*) AS count FROM
  58. ( SELECT COUNT(*) FROM cygx_yanxuan_special_record AS art WHERE 1 = 1 ` + condition + ` GROUP BY user_id ) f `
  59. o := orm.NewOrm()
  60. err = o.Raw(sqlCount, pars).QueryRow(&count)
  61. return
  62. }
  63. // 判断一个用户是否阅读过 某一篇研选专栏
  64. func GetCygxYanxuanSpecialRecordCountByUser(userId, yanxuanSpecialId int) (count int, err error) {
  65. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_record as a WHERE user_id= ? AND yanxuan_special_id = ? `
  66. o := orm.NewOrm()
  67. err = o.Raw(sqlCount, userId, yanxuanSpecialId).QueryRow(&count)
  68. return
  69. }
  70. // 详细日志记录,不过滤时长小于 3 秒的那种
  71. type CygxYanxuanSpecialRecordLog struct {
  72. CygxYanxuanSpecialRecordId int `orm:"column(cygx_yanxuan_special_record_id);pk"`
  73. UserId int // 用户ID
  74. Mobile string // 手机号
  75. Email string // 邮箱
  76. CompanyId int // 公司ID
  77. CompanyName string // 公司名称
  78. RealName string // 用户实际名称
  79. SellerName string // 所属销售
  80. CreateTime time.Time // 创建时间
  81. ModifyTime time.Time // 修改时间
  82. RegisterPlatform int // 来源 1小程序,2:网页
  83. YanxuanSpecialId int // cygx_yanxuan_special 表主键ID
  84. StopTime int // 停留时间
  85. }
  86. func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {
  87. o := orm.NewOrm()
  88. lastId, err = o.Insert(item)
  89. return
  90. }
  91. // 列表
  92. func GetCygxYanxuanSpecialRecordRespList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialRecordResp, err error) {
  93. o := orm.NewOrm()
  94. sql := `SELECT * FROM cygx_yanxuan_special_record as art WHERE 1= 1 `
  95. if condition != "" {
  96. sql += condition
  97. }
  98. sql += ` LIMIT ?,? `
  99. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  100. return
  101. }