report_cache.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package cache
  2. import (
  3. "fmt"
  4. "hongze/hongze_api/models"
  5. "hongze/hongze_api/utils"
  6. )
  7. // UserViewRedisData 阅读数据
  8. type UserViewRedisData struct {
  9. Mobile string `json:"mobile"`
  10. Email string `json:"email"`
  11. RealName string `json:"real_name"`
  12. CompanyName string `json:"company_name"`
  13. ViewTime string `json:"view_time" description:"阅读时间,格式:2022-02-17 13:06:13"`
  14. ProductId int `json:"product_id" description:"报告所属产品,ficc:1,权益:2"`
  15. CompanyId int `json:"company_id" description:"客户id"`
  16. }
  17. // PushViewRecordNewRedisData 阅读数据加入到redis
  18. func PushViewRecordNewRedisData(reportViewRecord *models.ReportViewRecord,companyId int) bool {
  19. data := &UserViewRedisData{
  20. Mobile: reportViewRecord.Mobile,
  21. Email: reportViewRecord.Email,
  22. RealName: reportViewRecord.RealName,
  23. CompanyName: reportViewRecord.CompanyName,
  24. ViewTime: reportViewRecord.CreateTime.Format(utils.FormatDateTime),
  25. ProductId: 1,
  26. CompanyId: companyId
  27. }
  28. if utils.Re == nil {
  29. err := utils.Rc.LPush(utils.CACHE_KEY_USER_VIEW, data)
  30. if err != nil {
  31. fmt.Println("PushViewRecordNewRedisData LPush Err:" + err.Error())
  32. }
  33. return true
  34. }
  35. return false
  36. }