|
|
package com.yoho.search.consumer.index.increment.otherIndex;
|
|
|
|
|
|
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.ISearchConstants;
|
|
|
import com.yoho.search.consumer.index.common.IYohoIndexService;
|
|
|
import com.yoho.search.consumer.index.fullbuild.BigdataSortBrandVectorW2vIndexBuilder;
|
|
|
import com.yoho.search.consumer.index.increment.AbstractMqListener;
|
|
|
import com.yoho.search.consumer.service.bo.BigdataSortBrandVectorBO;
|
|
|
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
|
|
|
import com.yoho.search.dal.model.BigdataSortBrandVectorW2v;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
@Component
|
|
|
@SearchMqConsumerListerner(tableName = "bigdata_sort_brand_vector_w2v")
|
|
|
public class BigdataSortBrandVectorW2vMqListener extends AbstractMqListener {
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(BigdataSortBrandVectorW2vMqListener.class);
|
|
|
|
|
|
@Autowired
|
|
|
private IYohoIndexService indexService;
|
|
|
@Autowired
|
|
|
private BigdataSortBrandVectorW2vIndexBuilder bigdataSortBrandVectorW2vIndexBuilder;
|
|
|
|
|
|
@Override
|
|
|
protected String getIndexName() {
|
|
|
return ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTORW2V;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected EventReportEnum getEventReportEnum() {
|
|
|
return EventReportEnum.BIGDATASORTBRANDVECTORW2VMQLISTENER_ONMESSAGE;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void deleteData(String id) throws Exception {
|
|
|
logger.error("[func=deleteData by id ][id={}]", id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void deleteDataByObject(final JSONObject data) throws Exception {
|
|
|
BigdataSortBrandVectorW2v bigdataSortBrandVector = ConvertUtils.toJavaObject(BigdataSortBrandVectorW2v.class, data);
|
|
|
if (bigdataSortBrandVector != null && bigdataSortBrandVector.getBrandId() != null && bigdataSortBrandVector.getMiddleSortId() != null) {
|
|
|
String indexId = bigdataSortBrandVector.getBrandId() + "_" + bigdataSortBrandVector.getMiddleSortId();
|
|
|
indexService.deleteIndexData(ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTORW2V, indexId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void updateData(JSONObject data) throws Exception {
|
|
|
BigdataSortBrandVectorW2v vector = ConvertUtils.toJavaObject(BigdataSortBrandVectorW2v.class, data);
|
|
|
if (vector != null && vector.getBrandId() != null && vector.getMiddleSortId() != null) {
|
|
|
BigdataSortBrandVectorBO vectorBO = bigdataSortBrandVectorW2vIndexBuilder.getBigdataSortBrandVectorBO(vector);
|
|
|
indexService.updateIndexData(ISearchConstants.INDEX_NAME_BIGDATASORTBRANDVECTORW2V, vectorBO.getId(), vectorBO);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|