Showing
8 changed files
with
280 additions
and
0 deletions
1 | +package com.yoho.search.dal; | ||
2 | + | ||
3 | +import com.yoho.search.dal.model.CsSearchRankConfig; | ||
4 | +import org.apache.ibatis.annotations.Param; | ||
5 | + | ||
6 | +import java.util.List; | ||
7 | + | ||
8 | +public interface CsSearchRankConfigMapper { | ||
9 | + int deleteByPrimaryKey(Integer id); | ||
10 | + | ||
11 | + int insert(CsSearchRankConfig record); | ||
12 | + | ||
13 | + int insertSelective(CsSearchRankConfig record); | ||
14 | + | ||
15 | + CsSearchRankConfig selectByPrimaryKey(Integer id); | ||
16 | + | ||
17 | + int updateByPrimaryKeySelective(CsSearchRankConfig record); | ||
18 | + | ||
19 | + int updateByPrimaryKey(CsSearchRankConfig record); | ||
20 | + | ||
21 | + int selectCount(); | ||
22 | + | ||
23 | + List<CsSearchRankConfig> selectPageLists(@Param(value = "start") Integer start, @Param(value = "limit") Integer limit); | ||
24 | +} |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.yoho.search.dal.CsSearchRankConfigMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.CsSearchRankConfig" > | ||
5 | + <id column="id" property="id" jdbcType="INTEGER" /> | ||
6 | + <result column="skn" property="skn" jdbcType="INTEGER" /> | ||
7 | + <result column="rank" property="rank" jdbcType="INTEGER" /> | ||
8 | + <result column="sale_num" property="saleNum" jdbcType="INTEGER" /> | ||
9 | + <result column="update_time" property="updateTime" jdbcType="INTEGER" /> | ||
10 | + </resultMap> | ||
11 | + | ||
12 | + <sql id="Base_Column_List" > | ||
13 | + id, skn, rank, sale_num, update_time | ||
14 | + </sql> | ||
15 | + | ||
16 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | ||
17 | + select | ||
18 | + <include refid="Base_Column_List" /> | ||
19 | + from cs_search_rank_config | ||
20 | + where id = #{id,jdbcType=INTEGER} | ||
21 | + </select> | ||
22 | + | ||
23 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | ||
24 | + delete from cs_search_rank_config | ||
25 | + where id = #{id,jdbcType=INTEGER} | ||
26 | + </delete> | ||
27 | + | ||
28 | + <insert id="insert" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" > | ||
29 | + insert into cs_search_rank_config (id, skn, rank, | ||
30 | + sale_num, update_time) | ||
31 | + values (#{id,jdbcType=INTEGER}, #{skn,jdbcType=INTEGER}, #{rank,jdbcType=INTEGER}, | ||
32 | + #{saleNum,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}) | ||
33 | + </insert> | ||
34 | + | ||
35 | + <insert id="insertSelective" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" > | ||
36 | + insert into cs_search_rank_config | ||
37 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
38 | + <if test="id != null" > | ||
39 | + id, | ||
40 | + </if> | ||
41 | + <if test="skn != null" > | ||
42 | + skn, | ||
43 | + </if> | ||
44 | + <if test="rank != null" > | ||
45 | + rank, | ||
46 | + </if> | ||
47 | + <if test="saleNum != null" > | ||
48 | + sale_num, | ||
49 | + </if> | ||
50 | + <if test="updateTime != null" > | ||
51 | + update_time, | ||
52 | + </if> | ||
53 | + </trim> | ||
54 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
55 | + <if test="id != null" > | ||
56 | + #{id,jdbcType=INTEGER}, | ||
57 | + </if> | ||
58 | + <if test="skn != null" > | ||
59 | + #{skn,jdbcType=INTEGER}, | ||
60 | + </if> | ||
61 | + <if test="rank != null" > | ||
62 | + #{rank,jdbcType=INTEGER}, | ||
63 | + </if> | ||
64 | + <if test="saleNum != null" > | ||
65 | + #{saleNum,jdbcType=INTEGER}, | ||
66 | + </if> | ||
67 | + <if test="updateTime != null" > | ||
68 | + #{updateTime,jdbcType=INTEGER}, | ||
69 | + </if> | ||
70 | + </trim> | ||
71 | + </insert> | ||
72 | + | ||
73 | + <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" > | ||
74 | + update cs_search_rank_config | ||
75 | + <set > | ||
76 | + <if test="skn != null" > | ||
77 | + skn = #{skn,jdbcType=INTEGER}, | ||
78 | + </if> | ||
79 | + <if test="rank != null" > | ||
80 | + rank = #{rank,jdbcType=INTEGER}, | ||
81 | + </if> | ||
82 | + <if test="saleNum != null" > | ||
83 | + sale_num = #{saleNum,jdbcType=INTEGER}, | ||
84 | + </if> | ||
85 | + <if test="updateTime != null" > | ||
86 | + update_time = #{updateTime,jdbcType=INTEGER}, | ||
87 | + </if> | ||
88 | + </set> | ||
89 | + where id = #{id,jdbcType=INTEGER} | ||
90 | + </update> | ||
91 | + | ||
92 | + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" > | ||
93 | + update cs_search_rank_config | ||
94 | + set skn = #{skn,jdbcType=INTEGER}, | ||
95 | + rank = #{rank,jdbcType=INTEGER}, | ||
96 | + sale_num = #{saleNum,jdbcType=INTEGER}, | ||
97 | + update_time = #{updateTime,jdbcType=INTEGER} | ||
98 | + where id = #{id,jdbcType=INTEGER} | ||
99 | + </update> | ||
100 | + | ||
101 | + <select id="selectCount" resultType="int"> | ||
102 | + select count(0) from cs_search_rank_config | ||
103 | + </select> | ||
104 | + | ||
105 | + <select id="selectPageLists" resultMap="BaseResultMap" timeout="20000"> | ||
106 | + select | ||
107 | + <include refid="Base_Column_List"/> | ||
108 | + from cs_search_rank_config limit #{start}, #{limit} | ||
109 | + </select> | ||
110 | +</mapper> |
index/src/main/java/com/yoho/search/consumer/index/fullbuild/CsSearchRankConfigIndexBuilder.java
0 → 100644
1 | +package com.yoho.search.consumer.index.fullbuild; | ||
2 | + | ||
3 | +import com.yoho.search.dal.CsSearchRankConfigMapper; | ||
4 | +import com.yoho.search.dal.model.CsSearchRankConfig; | ||
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/8 | ||
13 | + */ | ||
14 | + | ||
15 | +@Component | ||
16 | +public class CsSearchRankConfigIndexBuilder extends IIndexBuilder { | ||
17 | + | ||
18 | + @Autowired | ||
19 | + private CsSearchRankConfigMapper csSearchRankConfigMapper; | ||
20 | + | ||
21 | + @Override | ||
22 | + public int getTotalCount() throws Exception { | ||
23 | + return csSearchRankConfigMapper.selectCount(); | ||
24 | + } | ||
25 | + | ||
26 | + @Override | ||
27 | + public List<?> getPageLists(int offset, int limit) throws Exception { | ||
28 | + return csSearchRankConfigMapper.selectPageLists(offset, limit); | ||
29 | + } | ||
30 | + | ||
31 | + @Override | ||
32 | + public String getId(Object object) { | ||
33 | + return ((CsSearchRankConfig) object).getId().toString(); | ||
34 | + } | ||
35 | +} |
1 | +package com.yoho.search.consumer.index.increment.yhb_operations; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | +import com.yoho.search.base.utils.ConvertUtils; | ||
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; | ||
8 | +import com.yoho.search.core.message.beans.SearchMqConsumerListerner; | ||
9 | +import com.yoho.search.dal.CsSearchRankConfigMapper; | ||
10 | +import com.yoho.search.dal.model.CsSearchRankConfig; | ||
11 | +import org.springframework.beans.factory.annotation.Autowired; | ||
12 | +import org.springframework.stereotype.Component; | ||
13 | + | ||
14 | +/** | ||
15 | + * @author wangnan | ||
16 | + * @version 2019/5/8 | ||
17 | + */ | ||
18 | +@Component | ||
19 | +@SearchMqConsumerListerner(dbName = "yhb_operations", tableName = "cs_search_rank_config") | ||
20 | +public class CsSearchRankConfigMqListener extends AbstractMqListener { | ||
21 | + | ||
22 | + @Autowired | ||
23 | + private CsSearchRankConfigMapper csSearchRankConfigMapper; | ||
24 | + @Autowired | ||
25 | + private IYohoIndexService indexService; | ||
26 | + | ||
27 | + @Override | ||
28 | + public String getIndexName() { | ||
29 | + return ISearchConstants.INDEX_NAME_CS_SEARCH_RANK_CONFIG; | ||
30 | + } | ||
31 | + | ||
32 | + @Override | ||
33 | + protected void deleteData(String id) throws Exception { | ||
34 | + csSearchRankConfigMapper.deleteByPrimaryKey(Integer.valueOf(id)); | ||
35 | + indexService.deleteIndexData(this.getIndexName(), id); | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + protected void updateData(JSONObject data) throws Exception { | ||
40 | + CsSearchRankConfig csSearchRankConfig = ConvertUtils.toJavaObject(CsSearchRankConfig.class, data); | ||
41 | + if (csSearchRankConfig == null || csSearchRankConfig.getId() == null) { | ||
42 | + return; | ||
43 | + } | ||
44 | + this.saveOrUpdate(csSearchRankConfig); | ||
45 | + indexService.updateIndexData(this.getIndexName(), csSearchRankConfig.getId().toString(), csSearchRankConfig); | ||
46 | + } | ||
47 | + | ||
48 | + private int saveOrUpdate(CsSearchRankConfig csSearchRankConfig) { | ||
49 | + if (csSearchRankConfig.getId() == null || csSearchRankConfigMapper.selectByPrimaryKey(csSearchRankConfig.getId()) == null) { | ||
50 | + return csSearchRankConfigMapper.insertSelective(csSearchRankConfig); | ||
51 | + } else { | ||
52 | + return csSearchRankConfigMapper.updateByPrimaryKeySelective(csSearchRankConfig); | ||
53 | + } | ||
54 | + } | ||
55 | +} |
@@ -94,6 +94,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware { | @@ -94,6 +94,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware { | ||
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 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_POOL); |
97 | + this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RANK_CONFIG); | ||
97 | 98 | ||
98 | //重建pi | 99 | //重建pi |
99 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX); | 100 | this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX); |
1 | +{ | ||
2 | + "cssearchrankconfig": { | ||
3 | + "_all":{ | ||
4 | + "enabled":false | ||
5 | + }, | ||
6 | + "_source":{ | ||
7 | + "enabled":true | ||
8 | + }, | ||
9 | + "properties": { | ||
10 | + "id": { | ||
11 | + "type": "integer" | ||
12 | + }, | ||
13 | + "skn": { | ||
14 | + "type": "integer" | ||
15 | + }, | ||
16 | + "rank": { | ||
17 | + "type": "integer" | ||
18 | + }, | ||
19 | + "saleNum": { | ||
20 | + "type": "integer" | ||
21 | + }, | ||
22 | + "updateTime": { | ||
23 | + "type": "integer" | ||
24 | + } | ||
25 | + } | ||
26 | + } | ||
27 | +} |
@@ -710,5 +710,19 @@ | @@ -710,5 +710,19 @@ | ||
710 | <rebuildPageSize>2500</rebuildPageSize> | 710 | <rebuildPageSize>2500</rebuildPageSize> |
711 | </index> | 711 | </index> |
712 | 712 | ||
713 | + <index> | ||
714 | + <name>cssearchrankconfig</name> | ||
715 | + <properties> | ||
716 | + <property key="number_of_shards" value="1"/> | ||
717 | + <property key="number_of_replicas" value="auto"/> | ||
718 | + <property key="refresh_interval" value="10s"/> | ||
719 | + <property key="translog.flush_threshold_size" value="100mb"/> | ||
720 | + </properties> | ||
721 | + <builderClass>com.yoho.search.consumer.index.fullbuild.CsSearchRankConfigIndexBuilder</builderClass> | ||
722 | + <mappingFile>esmapping/cssearchrankconfig.json</mappingFile> | ||
723 | + <analysisFile>analysis/default.yml</analysisFile> | ||
724 | + <rebuildPageSize>2500</rebuildPageSize> | ||
725 | + </index> | ||
726 | + | ||
713 | </client> | 727 | </client> |
714 | </IndexConfigs> | 728 | </IndexConfigs> |
@@ -714,5 +714,19 @@ | @@ -714,5 +714,19 @@ | ||
714 | <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> | 714 | <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> |
715 | </index> | 715 | </index> |
716 | 716 | ||
717 | + <index> | ||
718 | + <name>cssearchrankconfig</name> | ||
719 | + <properties> | ||
720 | + <property key="number_of_shards" value="1"/> | ||
721 | + <property key="number_of_replicas" value="auto"/> | ||
722 | + <property key="refresh_interval" value="${search.index.refresh_interval}"/> | ||
723 | + <property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/> | ||
724 | + </properties> | ||
725 | + <builderClass>com.yoho.search.consumer.index.fullbuild.CsSearchRankConfigIndexBuilder</builderClass> | ||
726 | + <mappingFile>esmapping/cssearchrankconfig.json</mappingFile> | ||
727 | + <analysisFile>analysis/default.yml</analysisFile> | ||
728 | + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> | ||
729 | + </index> | ||
730 | + | ||
717 | </client> | 731 | </client> |
718 | </IndexConfigs> | 732 | </IndexConfigs> |
-
Please register or login to post a comment