report_history_record.go 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxReportHistoryRecord struct {
  7. Id int `orm:"column(id);pk"`
  8. ArticleId int
  9. UserId int
  10. CreateTime time.Time
  11. Mobile string `description:"手机号"`
  12. Email string `description:"邮箱"`
  13. CompanyId int `description:"公司id"`
  14. CompanyName string `description:"公司名称"`
  15. ModifyTime time.Time `description:"修改时间"`
  16. ReportType string `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
  17. RealName string `description:"用户实际名称"`
  18. SellerName string `description:"所属销售"`
  19. StopTime int `description:"停留时间"`
  20. OutType int `description:"退出方式,1正常退出,2强制关闭"`
  21. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  22. }
  23. type CygxReportHistoryRecordLog struct {
  24. Id int `orm:"column(id);pk"`
  25. ArticleId int
  26. UserId int
  27. CreateTime time.Time
  28. Mobile string `description:"手机号"`
  29. Email string `description:"邮箱"`
  30. CompanyId int `description:"公司id"`
  31. CompanyName string `description:"公司名称"`
  32. ModifyTime time.Time `description:"修改时间"`
  33. ReportType string `description:"报告类型,bgjx:报告精选、bzyjhz:本周研究汇总、szjyhz:上周纪要汇总"`
  34. RealName string `description:"用户实际名称"`
  35. SellerName string `description:"所属销售"`
  36. StopTime int `description:"停留时间"`
  37. OutType int `description:"退出方式,1正常退出,2强制关闭"`
  38. RegisterPlatform int `description:"来源 1小程序,2:网页"`
  39. }
  40. // 添加历史信息
  41. func AddCygxReportHistoryRecord(item *CygxReportHistoryRecord) (lastId int64, err error) {
  42. o := orm.NewOrm()
  43. item.ModifyTime = time.Now()
  44. lastId, err = o.Insert(item)
  45. return
  46. }
  47. // 添加历史信息
  48. func AddCygxReportHistoryRecordLog(item *CygxReportHistoryRecordLog) (lastId int64, err error) {
  49. o := orm.NewOrm()
  50. item.ModifyTime = time.Now()
  51. lastId, err = o.Insert(item)
  52. return
  53. }
  54. type ListPvResp struct {
  55. ArticleId int `description:"文章ID"`
  56. Pv int `description:"pv"`
  57. }
  58. // 列表
  59. func GetCygxReportHistoryRecordListPv(condition string, pars []interface{}) (items []*ListPvResp, err error) {
  60. o := orm.NewOrm()
  61. sql := `SELECT article_id ,COUNT(*) as pv FROM cygx_report_history_record WHERE 1= 1 `
  62. if condition != "" {
  63. sql += condition
  64. }
  65. sql += " GROUP BY article_id "
  66. _, err = o.Raw(sql, pars).QueryRows(&items)
  67. return
  68. }