wx_user_rai_label.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package services
  2. import (
  3. "fmt"
  4. "hongze/hongze_web_mfyx/models"
  5. "hongze/hongze_web_mfyx/utils"
  6. "time"
  7. )
  8. // 添加用户搜索标签到Redis
  9. func KeyWordsWxUserRaiLabelRedisAdd(sourceId, uid int, label string) (err error) {
  10. defer func() {
  11. if err != nil {
  12. fmt.Println(err)
  13. msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
  14. go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
  15. }
  16. }()
  17. log := &models.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 1, Label: label, CreateTime: time.Now(), RegisterPlatform: utils.REGISTER_PLATFORM}
  18. if utils.Re == nil {
  19. err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
  20. if err != nil {
  21. fmt.Println("WxUserRaiLabelRedis LPush Err:" + err.Error())
  22. }
  23. }
  24. return
  25. }
  26. // 添加用户阅读文章标签到Redis
  27. func ArticleWxUserRaiLabelRedisAdd(sourceId, uid int, createTime time.Time) (err error) {
  28. defer func() {
  29. if err != nil {
  30. fmt.Println(err)
  31. msg := fmt.Sprint("sourceId:", sourceId, "userId:", uid)
  32. go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
  33. }
  34. }()
  35. log := &models.WxUserRaiLabelRedis{UserId: uid, SourceId: sourceId, SourceType: 1, TableName: utils.CYGX_OBJ_ARTICLE, CreateTime: createTime, RegisterPlatform: utils.REGISTER_PLATFORM}
  36. if utils.Re == nil {
  37. err := utils.Rc.LPush(utils.WX_USER_RAI_LABEL_KEY, log)
  38. if err != nil {
  39. fmt.Println("WxUserRaiLabelRedis LPush Err:" + err.Error())
  40. }
  41. }
  42. return
  43. }