...
|
...
|
@@ -2,24 +2,41 @@ package com.yoho.search.consumer.index.increment.yhb_operations; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.search.base.utils.ConvertUtils;
|
|
|
import com.yoho.search.base.utils.EventReportEnum;
|
|
|
import com.yoho.search.base.utils.ProductIndexEsField;
|
|
|
import com.yoho.search.consumer.index.increment.AbstractMqListener;
|
|
|
import com.yoho.search.consumer.service.daoService.ProductService;
|
|
|
import com.yoho.search.consumer.service.logicService.CsRecommendSknPoolLogicService;
|
|
|
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
|
|
|
import com.yoho.search.dal.CsRecommendSknPoolMapper;
|
|
|
import com.yoho.search.dal.model.CsRecommendSknPool;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
@SearchMqConsumerListerner(dbName = "yhb_operations", tableName = "cs_recommend_skn_pool")
|
|
|
public class CsRecommendSknPoolMqListener extends AbstractMqListener {
|
|
|
|
|
|
@Autowired
|
|
|
private CsRecommendSknPoolMapper csRecommendSknPoolMapper;
|
|
|
@Autowired
|
|
|
private CsRecommendSknPoolLogicService csRecommendSknPoolLogicService;
|
|
|
@Autowired
|
|
|
private ProductService productService;
|
|
|
|
|
|
@Override
|
|
|
protected void deleteData(String id) throws Exception {
|
|
|
csRecommendSknPoolMapper.deleteByPrimaryKey(Integer.valueOf(id));
|
|
|
Integer idInt = Integer.valueOf(id);
|
|
|
CsRecommendSknPool csRecommendSknPool = csRecommendSknPoolMapper.selectByPrimaryKey(idInt);
|
|
|
if (csRecommendSknPool == null) {
|
|
|
return;
|
|
|
}
|
|
|
csRecommendSknPoolMapper.deleteByPrimaryKey(csRecommendSknPool.getId());
|
|
|
this.updateProductIndex(csRecommendSknPool.getSkn());
|
|
|
}
|
|
|
|
|
|
@Override
|
...
|
...
|
@@ -33,5 +50,21 @@ public class CsRecommendSknPoolMqListener extends AbstractMqListener { |
|
|
} else {
|
|
|
csRecommendSknPoolMapper.updateByPrimaryKey(csRecommendSknPool);
|
|
|
}
|
|
|
this.updateProductIndex(csRecommendSknPool.getSkn());
|
|
|
}
|
|
|
|
|
|
private void updateProductIndex(Integer skn) {
|
|
|
if (skn == null) {
|
|
|
return;
|
|
|
}
|
|
|
Integer productId = productService.selectProductIdBySkn(skn);
|
|
|
if (productId == null) {
|
|
|
return;
|
|
|
}
|
|
|
List<Integer> poolIds = csRecommendSknPoolLogicService.queryRecommendSknPools(skn);
|
|
|
Map<String, Object> indexData = new HashMap<>();
|
|
|
indexData.put(ProductIndexEsField.productId, productId);
|
|
|
indexData.put(ProductIndexEsField.toAddScorePoolIds, StringUtils.join(poolIds, ","));
|
|
|
this.updateProductIndexWithDataMap(indexData, productId);
|
|
|
}
|
|
|
} |
...
|
...
|
|