report_cache.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. StopTime int `json:"stop_time" description:"停留时间"`
  21. OutId int `json:"out_id" description:"章节ID"`
  22. }
  23. // PushViewRecordNewRedisData 阅读数据加入到redis
  24. func PushViewRecordNewRedisData(reportViewRecord *models.ReportViewRecord, companyId int) bool {
  25. data := &UserViewRedisData{
  26. Mobile: reportViewRecord.Mobile,
  27. Email: reportViewRecord.Email,
  28. RealName: reportViewRecord.RealName,
  29. CompanyName: reportViewRecord.CompanyName,
  30. ViewTime: reportViewRecord.CreateTime.Format(utils.FormatDateTime),
  31. ProductId: 1,
  32. CompanyId: companyId,
  33. UserId: reportViewRecord.UserId,
  34. ReportId: reportViewRecord.ReportId,
  35. OutId: reportViewRecord.Id,
  36. }
  37. err := go_redis.LPush(utils.CACHE_KEY_USER_VIEW, data)
  38. if err != nil {
  39. fmt.Println("PushViewRecordNewRedisData LPush Err:" + err.Error())
  40. }
  41. return true
  42. }