Authored by wangnan

优化mqlinster代码结构,减少重复代码

1 package com.yoho.search.consumer.index.increment.productIndex; 1 package com.yoho.search.consumer.index.increment.productIndex;
2 2
3 import com.alibaba.fastjson.JSONArray; 3 import com.alibaba.fastjson.JSONArray;
  4 +import com.alibaba.fastjson.JSONObject;
4 import com.rabbitmq.client.Channel; 5 import com.rabbitmq.client.Channel;
5 import com.yoho.error.event.SearchEvent; 6 import com.yoho.error.event.SearchEvent;
6 import com.yoho.search.base.utils.ConvertUtils; 7 import com.yoho.search.base.utils.ConvertUtils;
@@ -92,7 +93,8 @@ public class ActivityProductMqListener extends AbstractMqListener implements Cha @@ -92,7 +93,8 @@ public class ActivityProductMqListener extends AbstractMqListener implements Cha
92 Map<String, Object> indexData = new HashMap<>(); 93 Map<String, Object> indexData = new HashMap<>();
93 indexData.put("productId", productId); 94 indexData.put("productId", productId);
94 if (CollectionUtils.isEmpty(activityProducts)) { 95 if (CollectionUtils.isEmpty(activityProducts)) {
95 - indexData.put("activities", ""); 96 + jsonArray.add(new JSONObject());
  97 + indexData.put("activities", jsonArray);
96 }else{ 98 }else{
97 for (ActivityProduct activityProduct : activityProducts) { 99 for (ActivityProduct activityProduct : activityProducts) {
98 jsonArray.add(activityProductService.getActivities(activityProduct)); 100 jsonArray.add(activityProductService.getActivities(activityProduct));