report_cache.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package cache
  2. import (
  3. "fmt"
  4. "hongze/hongze_api/models"
  5. "hongze/hongze_api/services/go_redis"
  6. "hongze/hongze_api/utils"
  7. )
  8. // UserViewRedisData 阅读数据
  9. type UserViewRedisData struct {
  10. Mobile string `json:"mobile"`
  11. Email string `json:"email"`
  12. RealName string `json:"real_name"`
  13. CompanyName string `json:"company_name"`
  14. ViewTime string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
  15. ProductId int `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
  16. CompanyId int `json:"company_id" description:"客户id"`
  17. UserId int `json:"user_id" description:"用户id"`
  18. ReportId int `json:"report_id" description:"报告ID"`
  19. ReportChapterId int `json:"report_chapter_id" description:"章节ID"`
  20. Source int8 `json:"source" description:"来源,1:rddp的报告;2:weekly_report的PHP报告;3:weekly_report商品的报告(应该是作废了);4:察研观向的报告'"`
  21. StopTime int `json:"stop_time" description:"停留时间"`
  22. OutId int `json:"out_id" description:"章节ID"`
  23. }
  24. // PushViewRecordNewRedisData 阅读数据加入到redis
  25. func PushViewRecordNewRedisData(reportViewRecord *models.ReportViewRecord, companyId int) bool {
  26. data := &UserViewRedisData{
  27. Mobile: reportViewRecord.Mobile,
  28. Email: reportViewRecord.Email,
  29. RealName: reportViewRecord.RealName,
  30. CompanyName: reportViewRecord.CompanyName,
  31. ViewTime: reportViewRecord.CreateTime.Format(utils.FormatDateTime),
  32. ProductId: 1,
  33. CompanyId: companyId,
  34. UserId: reportViewRecord.UserId,
  35. ReportId: reportViewRecord.ReportId,
  36. OutId: reportViewRecord.Id,
  37. }
  38. err := go_redis.LPush(utils.CACHE_KEY_USER_VIEW, data)
  39. if err != nil {
  40. fmt.Println("PushViewRecordNewRedisData LPush Err:" + err.Error())
  41. }
  42. return true
  43. }