浏览代码

fix:id去重

duxin 2 年之前
父节点
当前提交
51e6b6b552
共有 1 个文件被更改,包括 10 次插入4 次删除
  1. 10 4
      jyBXSubscribe/rpc/internal/logic/bypushhistorylogic.go

+ 10 - 4
jyBXSubscribe/rpc/internal/logic/bypushhistorylogic.go

@@ -74,12 +74,18 @@ func (l *ByPushHistoryLogic) ByPushHistory(in *bxsubscribe.SubscribeInfosReq) (*
 	}
 	ids := make([]string, 0, len(list))
 	keyWords := make([]string, 0, len(list))
+	listMap := make(map[string]string)
+	//去重 防止list有重复数据
 	for _, pushData := range list {
 		if pushData.XId != "" {
-			if xid := util.DecodeId(pushData.XId); len(xid) > 0 {
-				ids = append(ids, xid)
-				keyWords = append(keyWords, strings.Join(pushData.MatchKeys, ","))
-			}
+			listMap[pushData.XId] = strings.Join(pushData.MatchKeys, ",")
+		}
+	}
+	//获取id与对应关键词
+	for k, v := range listMap {
+		if xid := util.DecodeId(k); len(xid) > 0 {
+			ids = append(ids, xid)
+			keyWords = append(keyWords, v)
 		}
 	}
 	saveData := map[string]interface{}{