productpool add backImageUrl
Showing
8 changed files
with
137 additions
and
11 deletions
1 | package com.yoho.search.dal; | 1 | package com.yoho.search.dal; |
2 | 2 | ||
3 | import com.yoho.search.dal.model.ProductPool; | 3 | import com.yoho.search.dal.model.ProductPool; |
4 | +import org.apache.ibatis.annotations.Param; | ||
4 | 5 | ||
5 | import java.util.List; | 6 | import java.util.List; |
6 | 7 | ||
@@ -16,4 +17,7 @@ public interface ProductPoolMapper { | @@ -16,4 +17,7 @@ public interface ProductPoolMapper { | ||
16 | 17 | ||
17 | List<ProductPool> selectByIds(List<Integer> ids); | 18 | List<ProductPool> selectByIds(List<Integer> ids); |
18 | 19 | ||
20 | + List<ProductPool> selectPageLists(@Param(value="offset")Integer offset, @Param(value="pageSize")Integer pageSize); | ||
21 | + | ||
22 | + int selectCount(); | ||
19 | } | 23 | } |
@@ -10,9 +10,10 @@ | @@ -10,9 +10,10 @@ | ||
10 | <result column="diff_type" property="diffType" jdbcType="CHAR"/> | 10 | <result column="diff_type" property="diffType" jdbcType="CHAR"/> |
11 | <result column="create_time" property="createTime" jdbcType="INTEGER"/> | 11 | <result column="create_time" property="createTime" jdbcType="INTEGER"/> |
12 | <result column="shop_id" property="shopId" jdbcType="INTEGER"/> | 12 | <result column="shop_id" property="shopId" jdbcType="INTEGER"/> |
13 | + <result column="backImageUrl" property="backImageUrl" jdbcType="VARCHAR"/> | ||
13 | </resultMap> | 14 | </resultMap> |
14 | <sql id="Base_Column_List"> | 15 | <sql id="Base_Column_List"> |
15 | - id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id | 16 | + id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id, backImageUrl |
16 | </sql> | 17 | </sql> |
17 | 18 | ||
18 | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer"> | 19 | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer"> |
@@ -42,9 +43,10 @@ | @@ -42,9 +43,10 @@ | ||
42 | 43 | ||
43 | 44 | ||
44 | <insert id="insert" parameterType="com.yoho.search.dal.model.ProductPool"> | 45 | <insert id="insert" parameterType="com.yoho.search.dal.model.ProductPool"> |
45 | - insert into product_pool (id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id) | 46 | + insert into product_pool (id, activityId, pool_name, comment, productType, diff_type, create_time, shop_id, backImageUrl) |
46 | values (#{id,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{poolName,jdbcType=VARCHAR}, | 47 | values (#{id,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{poolName,jdbcType=VARCHAR}, |
47 | - #{comment,jdbcType=VARCHAR}, #{productType,jdbcType=CHAR}, #{diffType,jdbcType=CHAR}, #{createTime,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}) | 48 | + #{comment,jdbcType=VARCHAR}, #{productType,jdbcType=CHAR}, #{diffType,jdbcType=CHAR}, |
49 | + #{createTime,jdbcType=INTEGER}, #{shopId,jdbcType=INTEGER}, #{backImageUrl,jdbcType=VARCHAR}) | ||
48 | </insert> | 50 | </insert> |
49 | 51 | ||
50 | <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductPool"> | 52 | <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductPool"> |
@@ -71,8 +73,21 @@ | @@ -71,8 +73,21 @@ | ||
71 | <if test="shopId != null"> | 73 | <if test="shopId != null"> |
72 | shop_id = #{shopId,jdbcType=INTEGER}, | 74 | shop_id = #{shopId,jdbcType=INTEGER}, |
73 | </if> | 75 | </if> |
76 | + <if test="backImageUrl != null"> | ||
77 | + backImageUrl = #{backImageUrl,jdbcType=VARCHAR}, | ||
78 | + </if> | ||
74 | </set> | 79 | </set> |
75 | where id = #{id,jdbcType=INTEGER} | 80 | where id = #{id,jdbcType=INTEGER} |
76 | </update> | 81 | </update> |
77 | 82 | ||
83 | + <select id="selectCount" resultType="java.lang.Integer" timeout="20000"> | ||
84 | + SELECT count(1) FROM product_pool | ||
85 | + </select> | ||
86 | + | ||
87 | + <select id="selectPageLists" resultMap="BaseResultMap" timeout="20000"> | ||
88 | + select | ||
89 | + <include refid="Base_Column_List" /> | ||
90 | + from product_pool limit #{offset},#{pageSize} | ||
91 | + </select> | ||
92 | + | ||
78 | </mapper> | 93 | </mapper> |
index/src/main/java/com/yoho/search/consumer/index/fullbuild/ProductPoolIndexBuilder.java
0 → 100644
1 | +package com.yoho.search.consumer.index.fullbuild; | ||
2 | + | ||
3 | +import com.yoho.search.dal.ProductPoolMapper; | ||
4 | +import com.yoho.search.dal.model.ProductPool; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.stereotype.Component; | ||
7 | + | ||
8 | +import java.util.List; | ||
9 | + | ||
10 | +/** | ||
11 | + * @author wangnan | ||
12 | + * @version 2019/5/6 | ||
13 | + */ | ||
14 | +@Component | ||
15 | +public class ProductPoolIndexBuilder extends IIndexBuilder { | ||
16 | + | ||
17 | + @Autowired | ||
18 | + private ProductPoolMapper productPoolMapper; | ||
19 | + | ||
20 | + @Override | ||
21 | + public int getTotalCount() throws Exception { | ||
22 | + return productPoolMapper.selectCount(); | ||
23 | + } | ||
24 | + | ||
25 | + @Override | ||
26 | + public List<?> getPageLists(int offset, int limit) throws Exception { | ||
27 | + return productPoolMapper.selectPageLists(offset, limit); | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public String getId(Object object) { | ||
32 | + return ((ProductPool) object).getId().toString(); | ||
33 | + } | ||
34 | +} |
@@ -2,8 +2,8 @@ package com.yoho.search.consumer.index.increment.erp_product; | @@ -2,8 +2,8 @@ package com.yoho.search.consumer.index.increment.erp_product; | ||
2 | 2 | ||
3 | import com.alibaba.fastjson.JSONObject; | 3 | import com.alibaba.fastjson.JSONObject; |
4 | import com.yoho.search.base.utils.ConvertUtils; | 4 | import com.yoho.search.base.utils.ConvertUtils; |
5 | -import com.yoho.search.base.utils.EventReportEnum; | ||
6 | import com.yoho.search.base.utils.ISearchConstants; | 5 | import com.yoho.search.base.utils.ISearchConstants; |
6 | +import com.yoho.search.consumer.common.IYohoIndexService; | ||
7 | import com.yoho.search.consumer.index.increment.AbstractMqListener; | 7 | import com.yoho.search.consumer.index.increment.AbstractMqListener; |
8 | import com.yoho.search.consumer.service.daoService.ProductPoolService; | 8 | import com.yoho.search.consumer.service.daoService.ProductPoolService; |
9 | import com.yoho.search.core.message.beans.SearchMqConsumerListerner; | 9 | import com.yoho.search.core.message.beans.SearchMqConsumerListerner; |
@@ -17,10 +17,12 @@ public class ProductPoolMqListener extends AbstractMqListener { | @@ -17,10 +17,12 @@ public class ProductPoolMqListener extends AbstractMqListener { | ||
17 | 17 | ||
18 | @Autowired | 18 | @Autowired |
19 | private ProductPoolService productPoolService; | 19 | private ProductPoolService productPoolService; |
20 | + @Autowired | ||
21 | + private IYohoIndexService indexService; | ||
20 | 22 | ||
21 | @Override | 23 | @Override |
22 | public String getIndexName() { | 24 | public String getIndexName() { |
23 | - return ISearchConstants.INDEX_NAME_PRODUCT_INDEX; | 25 | + return ISearchConstants.INDEX_NAME_PRODUCT_POOL; |
24 | } | 26 | } |
25 | 27 | ||
26 | @Override | 28 | @Override |
@@ -30,6 +32,7 @@ public class ProductPoolMqListener extends AbstractMqListener { | @@ -30,6 +32,7 @@ public class ProductPoolMqListener extends AbstractMqListener { | ||
30 | return; | 32 | return; |
31 | } | 33 | } |
32 | productPoolService.deleteByPrimaryKey(productPool.getId()); | 34 | productPoolService.deleteByPrimaryKey(productPool.getId()); |
35 | + indexService.deleteIndexData(this.getIndexName(), id); | ||
33 | } | 36 | } |
34 | 37 | ||
35 | @Override | 38 | @Override |
@@ -46,6 +49,8 @@ public class ProductPoolMqListener extends AbstractMqListener { | @@ -46,6 +49,8 @@ public class ProductPoolMqListener extends AbstractMqListener { | ||
46 | } | 49 | } |
47 | // 1)更新DB | 50 | // 1)更新DB |
48 | productPoolService.saveOrUpdate(productPool); | 51 | productPoolService.saveOrUpdate(productPool); |
52 | + String idValue = String.valueOf(productPool.getId()); | ||
53 | + indexService.updateIndexData(this.getIndexName(), idValue, JSONObject.toJSON(productPool)); | ||
49 | } | 54 | } |
50 | 55 | ||
51 | } | 56 | } |
@@ -93,6 +93,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware { | @@ -93,6 +93,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware { | ||
93 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_SEARCH_LABLE); | 93 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_SEARCH_LABLE); |
94 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SALES_CATEGORY_SEARCH_LABLE); | 94 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SALES_CATEGORY_SEARCH_LABLE); |
95 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE); | 95 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE); |
96 | + this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_POOL); | ||
96 | 97 | ||
97 | //重建pi | 98 | //重建pi |
98 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX); | 99 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX); |
1 | +{ | ||
2 | + "productpool": { | ||
3 | + "_all": { | ||
4 | + "enabled": false | ||
5 | + }, | ||
6 | + "_source": { | ||
7 | + "enabled": true | ||
8 | + }, | ||
9 | + "properties": { | ||
10 | + "id": { | ||
11 | + "type": "long" | ||
12 | + }, | ||
13 | + "activityId": { | ||
14 | + "type": "long" | ||
15 | + }, | ||
16 | + "poolName": { | ||
17 | + "type": "keyword" | ||
18 | + }, | ||
19 | + "comment": { | ||
20 | + "type": "keyword" | ||
21 | + }, | ||
22 | + "productType": { | ||
23 | + "type": "keyword" | ||
24 | + }, | ||
25 | + "diffType": { | ||
26 | + "type": "keyword" | ||
27 | + }, | ||
28 | + "createTime": { | ||
29 | + "type": "long" | ||
30 | + }, | ||
31 | + "shopId": { | ||
32 | + "type": "long" | ||
33 | + }, | ||
34 | + "backImageUrl": { | ||
35 | + "type": "keyword" | ||
36 | + } | ||
37 | + } | ||
38 | + } | ||
39 | +} |
@@ -696,5 +696,19 @@ | @@ -696,5 +696,19 @@ | ||
696 | <rebuildPageSize>2500</rebuildPageSize> | 696 | <rebuildPageSize>2500</rebuildPageSize> |
697 | </index> | 697 | </index> |
698 | 698 | ||
699 | + <index> | ||
700 | + <name>productpool</name> | ||
701 | + <properties> | ||
702 | + <property key="number_of_shards" value="1"/> | ||
703 | + <property key="number_of_replicas" value="auto"/> | ||
704 | + <property key="refresh_interval" value="10s"/> | ||
705 | + <property key="translog.flush_threshold_size" value="100mb"/> | ||
706 | + </properties> | ||
707 | + <builderClass>com.yoho.search.consumer.index.fullbuild.ProductPoolIndexBuilder</builderClass> | ||
708 | + <mappingFile>esmapping/productpool.json</mappingFile> | ||
709 | + <analysisFile>analysis/default.yml</analysisFile> | ||
710 | + <rebuildPageSize>2500</rebuildPageSize> | ||
711 | + </index> | ||
712 | + | ||
699 | </client> | 713 | </client> |
700 | </IndexConfigs> | 714 | </IndexConfigs> |
@@ -640,13 +640,13 @@ | @@ -640,13 +640,13 @@ | ||
640 | <builderClass>com.yoho.search.consumer.index.fullbuild.CsRecallConfigBrandIndexBuilder</builderClass> | 640 | <builderClass>com.yoho.search.consumer.index.fullbuild.CsRecallConfigBrandIndexBuilder</builderClass> |
641 | <mappingFile>esmapping/csrecallconfigbrand.json</mappingFile> | 641 | <mappingFile>esmapping/csrecallconfigbrand.json</mappingFile> |
642 | <analysisFile>analysis/default.yml</analysisFile> | 642 | <analysisFile>analysis/default.yml</analysisFile> |
643 | - <rebuildPageSize>2500</rebuildPageSize> | 643 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> |
644 | </index> | 644 | </index> |
645 | 645 | ||
646 | <index> | 646 | <index> |
647 | <name>csrecallconfigsortprice</name> | 647 | <name>csrecallconfigsortprice</name> |
648 | <properties> | 648 | <properties> |
649 | - <property key="number_of_shards" value="1"/> | 649 | + <property key="number_of_shards" value="1"/ |
650 | <property key="number_of_replicas" value="auto"/> | 650 | <property key="number_of_replicas" value="auto"/> |
651 | <property key="refresh_interval" value="${search.index.refresh_interval}"/> | 651 | <property key="refresh_interval" value="${search.index.refresh_interval}"/> |
652 | <property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/> | 652 | <property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/> |
@@ -654,7 +654,7 @@ | @@ -654,7 +654,7 @@ | ||
654 | <builderClass>com.yoho.search.consumer.index.fullbuild.CsRecallConfigSortPriceIndexBuilder</builderClass> | 654 | <builderClass>com.yoho.search.consumer.index.fullbuild.CsRecallConfigSortPriceIndexBuilder</builderClass> |
655 | <mappingFile>esmapping/csrecallconfigsortprice.json</mappingFile> | 655 | <mappingFile>esmapping/csrecallconfigsortprice.json</mappingFile> |
656 | <analysisFile>analysis/default.yml</analysisFile> | 656 | <analysisFile>analysis/default.yml</analysisFile> |
657 | - <rebuildPageSize>2500</rebuildPageSize> | 657 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> |
658 | </index> | 658 | </index> |
659 | 659 | ||
660 | 660 | ||
@@ -669,7 +669,7 @@ | @@ -669,7 +669,7 @@ | ||
669 | <builderClass>com.yoho.search.consumer.index.fullbuild.ProductSearchLabelIndexBuilder</builderClass> | 669 | <builderClass>com.yoho.search.consumer.index.fullbuild.ProductSearchLabelIndexBuilder</builderClass> |
670 | <mappingFile>esmapping/productsearchlabel.json</mappingFile> | 670 | <mappingFile>esmapping/productsearchlabel.json</mappingFile> |
671 | <analysisFile>analysis/default.yml</analysisFile> | 671 | <analysisFile>analysis/default.yml</analysisFile> |
672 | - <rebuildPageSize>2500</rebuildPageSize> | 672 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> |
673 | </index> | 673 | </index> |
674 | 674 | ||
675 | <index> | 675 | <index> |
@@ -683,7 +683,7 @@ | @@ -683,7 +683,7 @@ | ||
683 | <builderClass>com.yoho.search.consumer.index.fullbuild.SalesCategorySearchLabelIndexBuilder</builderClass> | 683 | <builderClass>com.yoho.search.consumer.index.fullbuild.SalesCategorySearchLabelIndexBuilder</builderClass> |
684 | <mappingFile>esmapping/salescategorysearchlabel.json</mappingFile> | 684 | <mappingFile>esmapping/salescategorysearchlabel.json</mappingFile> |
685 | <analysisFile>analysis/default.yml</analysisFile> | 685 | <analysisFile>analysis/default.yml</analysisFile> |
686 | - <rebuildPageSize>2500</rebuildPageSize> | 686 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> |
687 | </index> | 687 | </index> |
688 | 688 | ||
689 | <index> | 689 | <index> |
@@ -697,7 +697,21 @@ | @@ -697,7 +697,21 @@ | ||
697 | <builderClass>com.yoho.search.consumer.index.fullbuild.CsSearchResourceBuilder</builderClass> | 697 | <builderClass>com.yoho.search.consumer.index.fullbuild.CsSearchResourceBuilder</builderClass> |
698 | <mappingFile>esmapping/cssearchresource.json</mappingFile> | 698 | <mappingFile>esmapping/cssearchresource.json</mappingFile> |
699 | <analysisFile>analysis/default.yml</analysisFile> | 699 | <analysisFile>analysis/default.yml</analysisFile> |
700 | - <rebuildPageSize>2500</rebuildPageSize> | 700 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> |
701 | + </index> | ||
702 | + | ||
703 | + <index> | ||
704 | + <name>productpool</name> | ||
705 | + <properties> | ||
706 | + <property key="number_of_shards" value="1"/> | ||
707 | + <property key="number_of_replicas" value="auto"/> | ||
708 | + <property key="refresh_interval" value="${search.index.refresh_interval}"/> | ||
709 | + <property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/> | ||
710 | + </properties> | ||
711 | + <builderClass>com.yoho.search.consumer.index.fullbuild.ProductPoolIndexBuilder</builderClass> | ||
712 | + <mappingFile>esmapping/productpool.json</mappingFile> | ||
713 | + <analysisFile>analysis/default.yml</analysisFile> | ||
714 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> | ||
701 | </index> | 715 | </index> |
702 | 716 | ||
703 | </client> | 717 | </client> |
-
Please register or login to post a comment