|
@@ -0,0 +1,63 @@
|
|
|
+package services
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "hongze/hongze_cygx/models"
|
|
|
+ "hongze/hongze_cygx/utils"
|
|
|
+)
|
|
|
+
|
|
|
+func UserLabelLogReduce() (err error) {
|
|
|
+ for {
|
|
|
+ //SourceType int `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
|
|
|
+ utils.Rc.Brpop(utils.CYGX_USER_KEY_LABEL, func(b []byte) {
|
|
|
+ var log models.CygxUserLabelLogRedis
|
|
|
+ if err := json.Unmarshal(b, &log); err != nil {
|
|
|
+ fmt.Println("json unmarshal wrong!")
|
|
|
+ go utils.SendAlarmMsg("用户更新相关标签处理Redis队列消息失败:"+err.Error()+string(b), 2)
|
|
|
+ }
|
|
|
+ switch log.SourceType {
|
|
|
+ case 1:
|
|
|
+ fmt.Println("文章阅读")
|
|
|
+ break
|
|
|
+ case 2:
|
|
|
+ go IndustryFllowUserLabelLogReduce(log)
|
|
|
+ fmt.Println("2产业关注")
|
|
|
+ break
|
|
|
+ case 3:
|
|
|
+ fmt.Println("活动到会")
|
|
|
+ break
|
|
|
+ case 4:
|
|
|
+ fmt.Println("4系列关注")
|
|
|
+ break
|
|
|
+ case 5:
|
|
|
+ fmt.Println("5专项调研活动到会")
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ fmt.Println(string(b))
|
|
|
+ go utils.SendAlarmMsg("用户更新相关标签处理Redis队列消息失败:"+string(b), 2)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+func IndustryFllowUserLabelLogReduce(log models.CygxUserLabelLogRedis) (err error) {
|
|
|
+ defer func() {
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ //msg := fmt.Sprint("industrialManagementId:", industrialManagementId, "isFllow:", isFllow, "userId:", uid)
|
|
|
+ msg := ""
|
|
|
+ go utils.SendAlarmMsg("用户关注产业更新相关标签,写入Redis队列消息失败:"+err.Error()+msg, 2)
|
|
|
+ }
|
|
|
+ }()
|
|
|
+
|
|
|
+ //type CygxActivitySigninLogRedis struct {
|
|
|
+ // UserId int `description:"用户ID"`
|
|
|
+ // SourceId int `description:"资源ID"`
|
|
|
+ // SourceType int `description:"1:文章阅读、 2产业关注、3:活动到会、4系列关注、5专项调研活动到会。"`
|
|
|
+ // IsFllow int `description:"1关注、0取消关注"`
|
|
|
+ // CreateTime time.Time `description:"创建时间"`
|
|
|
+ //}
|
|
|
+
|
|
|
+ return
|
|
|
+}
|