Authored by wangnan9279

productpool add backImageUrl

package com.yoho.search.dal;
import com.yoho.search.dal.model.ProductPool;
import org.apache.ibatis.annotations.Param;
import java.util.List;
... ... @@ -16,4 +17,7 @@ public interface ProductPoolMapper {
List<ProductPool> selectByIds(List<Integer> ids);
List<ProductPool> selectPageLists(@Param(value="offset")Integer offset, @Param(value="pageSize")Integer pageSize);
int selectCount();
}
... ...
... ... @@ -10,9 +10,10 @@
<result column="diff_type" property="diffType" jdbcType="CHAR"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="shop_id" property="shopId" jdbcType="INTEGER"/>
<result column="backImageUrl" property="backImageUrl" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id
id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id, backImageUrl
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
... ... @@ -42,9 +43,10 @@
<insert id="insert" parameterType="com.yoho.search.dal.model.ProductPool">
insert into product_pool (id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id)
insert into product_pool (id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id, backImageUrl)
values (#{id,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{poolName,jdbcType=VARCHAR},
#{comment,jdbcType=VARCHAR}, #{productType,jdbcType=CHAR}, #{diffType,jdbcType=CHAR}, #{createTime,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER})
#{comment,jdbcType=VARCHAR}, #{productType,jdbcType=CHAR}, #{diffType,jdbcType=CHAR},
#{createTime,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{backImageUrl,jdbcType=VARCHAR})
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductPool">
... ... @@ -71,8 +73,21 @@
<if test="shopId != null">
shop_id = #{shopId,jdbcType=INTEGER},
</if>
<if test="backImageUrl != null">
backImageUrl = #{backImageUrl,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer" timeout="20000">
SELECT count(1) FROM product_pool
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List" />
from product_pool limit #{offset},#{pageSize}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.dal.ProductPoolMapper;
import com.yoho.search.dal.model.ProductPool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author wangnan
* @version 2019/5/6
*/
@Component
public class ProductPoolIndexBuilder extends IIndexBuilder {
@Autowired
private ProductPoolMapper productPoolMapper;
@Override
public int getTotalCount() throws Exception {
return productPoolMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return productPoolMapper.selectPageLists(offset, limit);
}
@Override
public String getId(Object object) {
return ((ProductPool) object).getId().toString();
}
}
... ...
... ... @@ -2,8 +2,8 @@ package com.yoho.search.consumer.index.increment.erp_product;
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.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ProductPoolService;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
... ... @@ -17,10 +17,12 @@ public class ProductPoolMqListener extends AbstractMqListener {
@Autowired
private ProductPoolService productPoolService;
@Autowired
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
return ISearchConstants.INDEX_NAME_PRODUCT_POOL;
}
@Override
... ... @@ -30,6 +32,7 @@ public class ProductPoolMqListener extends AbstractMqListener {
return;
}
productPoolService.deleteByPrimaryKey(productPool.getId());
indexService.deleteIndexData(this.getIndexName(), id);
}
@Override
... ... @@ -46,6 +49,8 @@ public class ProductPoolMqListener extends AbstractMqListener {
}
// 1)更新DB
productPoolService.saveOrUpdate(productPool);
String idValue = String.valueOf(productPool.getId());
indexService.updateIndexData(this.getIndexName(), idValue, JSONObject.toJSON(productPool));
}
}
... ...
... ... @@ -93,6 +93,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_SEARCH_LABLE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SALES_CATEGORY_SEARCH_LABLE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_POOL);
//重建pi
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
... ...
{
"productpool": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"id": {
"type": "long"
},
"activityId": {
"type": "long"
},
"poolName": {
"type": "keyword"
},
"comment": {
"type": "keyword"
},
"productType": {
"type": "keyword"
},
"diffType": {
"type": "keyword"
},
"createTime": {
"type": "long"
},
"shopId": {
"type": "long"
},
"backImageUrl": {
"type": "keyword"
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -696,5 +696,19 @@
<rebuildPageSize>2500</rebuildPageSize>
</index>
<index>
<name>productpool</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="auto"/>
<property key="refresh_interval" value="10s"/>
<property key="translog.flush_threshold_size" value="100mb"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.ProductPoolIndexBuilder</builderClass>
<mappingFile>esmapping/productpool.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -640,13 +640,13 @@
<builderClass>com.yoho.search.consumer.index.fullbuild.CsRecallConfigBrandIndexBuilder</builderClass>
<mappingFile>esmapping/csrecallconfigbrand.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
<name>csrecallconfigsortprice</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_shards" value="1"/
<property key="number_of_replicas" value="auto"/>
<property key="refresh_interval" value="${search.index.refresh_interval}"/>
<property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/>
... ... @@ -654,7 +654,7 @@
<builderClass>com.yoho.search.consumer.index.fullbuild.CsRecallConfigSortPriceIndexBuilder</builderClass>
<mappingFile>esmapping/csrecallconfigsortprice.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
... ... @@ -669,7 +669,7 @@
<builderClass>com.yoho.search.consumer.index.fullbuild.ProductSearchLabelIndexBuilder</builderClass>
<mappingFile>esmapping/productsearchlabel.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
... ... @@ -683,7 +683,7 @@
<builderClass>com.yoho.search.consumer.index.fullbuild.SalesCategorySearchLabelIndexBuilder</builderClass>
<mappingFile>esmapping/salescategorysearchlabel.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
... ... @@ -697,7 +697,21 @@
<builderClass>com.yoho.search.consumer.index.fullbuild.CsSearchResourceBuilder</builderClass>
<mappingFile>esmapping/cssearchresource.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
<name>productpool</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="auto"/>
<property key="refresh_interval" value="${search.index.refresh_interval}"/>
<property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.ProductPoolIndexBuilder</builderClass>
<mappingFile>esmapping/productpool.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
</client>
... ...