Authored by wangnan9279

Merge branch '0930' into 1010

  1 +package com.yoho.search.dal;
  2 +
  3 +import com.yoho.search.dal.model.ProductCoverActivity;
  4 +import org.apache.ibatis.annotations.Param;
  5 +
  6 +import java.util.List;
  7 +
  8 +public interface ProductCoverActivityMapper {
  9 + int deleteByPrimaryKey(Integer id);
  10 +
  11 + int insert(ProductCoverActivity record);
  12 +
  13 + int insertSelective(ProductCoverActivity record);
  14 +
  15 + ProductCoverActivity selectByPrimaryKey(Integer id);
  16 +
  17 + int updateByPrimaryKeySelective(ProductCoverActivity record);
  18 +
  19 + int updateByPrimaryKey(ProductCoverActivity record);
  20 +
  21 + List<ProductCoverActivity> selectPageLists(@Param(value="offset")Integer offset, @Param(value="pageSize")Integer pageSize);
  22 +
  23 + int selectCount();
  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.ProductCoverActivityMapper">
  4 + <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductCoverActivity">
  5 + <id column="id" property="id" jdbcType="INTEGER"/>
  6 + <result column="product_skn" property="productSkn" jdbcType="INTEGER"/>
  7 + <result column="begin_time" property="beginTime" jdbcType="INTEGER"/>
  8 + <result column="end_time" property="endTime" jdbcType="INTEGER"/>
  9 + <result column="content_one" property="contentOne" jdbcType="VARCHAR"/>
  10 + <result column="content_two" property="contentTwo" jdbcType="VARCHAR"/>
  11 + <result column="order_by" property="orderBy" jdbcType="INTEGER"/>
  12 + <result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
  13 + <result column="create_time" property="createTime" jdbcType="INTEGER"/>
  14 + <result column="update_time" property="updateTime" jdbcType="INTEGER"/>
  15 + <result column="status" property="status" jdbcType="TINYINT"/>
  16 + </resultMap>
  17 + <sql id="Base_Column_List">
  18 + id, product_skn, begin_time, end_time, content_one, content_two, order_by, image_url,
  19 + create_time, update_time, status
  20 + </sql>
  21 + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  22 + select
  23 + <include refid="Base_Column_List"/>
  24 + from product_cover_activity
  25 + where id = #{id,jdbcType=INTEGER}
  26 + </select>
  27 + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  28 + delete from product_cover_activity
  29 + where id = #{id,jdbcType=INTEGER}
  30 + </delete>
  31 + <insert id="insert" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
  32 + insert into product_cover_activity (id, product_skn, begin_time,
  33 + end_time, content_one, content_two,
  34 + order_by, image_url, create_time,
  35 + update_time, status)
  36 + values (#{id,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{beginTime,jdbcType=INTEGER},
  37 + #{endTime,jdbcType=INTEGER}, #{contentOne,jdbcType=VARCHAR}, #{contentTwo,jdbcType=VARCHAR},
  38 + #{orderBy,jdbcType=INTEGER}, #{imageUrl,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER},
  39 + #{updateTime,jdbcType=INTEGER}, #{status,jdbcType=TINYINT})
  40 + </insert>
  41 + <insert id="insertSelective" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
  42 + insert into product_cover_activity
  43 + <trim prefix="(" suffix=")" suffixOverrides=",">
  44 + <if test="id != null">
  45 + id,
  46 + </if>
  47 + <if test="productSkn != null">
  48 + product_skn,
  49 + </if>
  50 + <if test="beginTime != null">
  51 + begin_time,
  52 + </if>
  53 + <if test="endTime != null">
  54 + end_time,
  55 + </if>
  56 + <if test="contentOne != null">
  57 + content_one,
  58 + </if>
  59 + <if test="contentTwo != null">
  60 + content_two,
  61 + </if>
  62 + <if test="orderBy != null">
  63 + order_by,
  64 + </if>
  65 + <if test="imageUrl != null">
  66 + image_url,
  67 + </if>
  68 + <if test="createTime != null">
  69 + create_time,
  70 + </if>
  71 + <if test="updateTime != null">
  72 + update_time,
  73 + </if>
  74 + <if test="status != null">
  75 + status,
  76 + </if>
  77 + </trim>
  78 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  79 + <if test="id != null">
  80 + #{id,jdbcType=INTEGER},
  81 + </if>
  82 + <if test="productSkn != null">
  83 + #{productSkn,jdbcType=INTEGER},
  84 + </if>
  85 + <if test="beginTime != null">
  86 + #{beginTime,jdbcType=INTEGER},
  87 + </if>
  88 + <if test="endTime != null">
  89 + #{endTime,jdbcType=INTEGER},
  90 + </if>
  91 + <if test="contentOne != null">
  92 + #{contentOne,jdbcType=VARCHAR},
  93 + </if>
  94 + <if test="contentTwo != null">
  95 + #{contentTwo,jdbcType=VARCHAR},
  96 + </if>
  97 + <if test="orderBy != null">
  98 + #{orderBy,jdbcType=INTEGER},
  99 + </if>
  100 + <if test="imageUrl != null">
  101 + #{imageUrl,jdbcType=VARCHAR},
  102 + </if>
  103 + <if test="createTime != null">
  104 + #{createTime,jdbcType=INTEGER},
  105 + </if>
  106 + <if test="updateTime != null">
  107 + #{updateTime,jdbcType=INTEGER},
  108 + </if>
  109 + <if test="status != null">
  110 + #{status,jdbcType=TINYINT},
  111 + </if>
  112 + </trim>
  113 + </insert>
  114 + <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
  115 + update product_cover_activity
  116 + <set>
  117 + <if test="productSkn != null">
  118 + product_skn = #{productSkn,jdbcType=INTEGER},
  119 + </if>
  120 + <if test="beginTime != null">
  121 + begin_time = #{beginTime,jdbcType=INTEGER},
  122 + </if>
  123 + <if test="endTime != null">
  124 + end_time = #{endTime,jdbcType=INTEGER},
  125 + </if>
  126 + <if test="contentOne != null">
  127 + content_one = #{contentOne,jdbcType=VARCHAR},
  128 + </if>
  129 + <if test="contentTwo != null">
  130 + content_two = #{contentTwo,jdbcType=VARCHAR},
  131 + </if>
  132 + <if test="orderBy != null">
  133 + order_by = #{orderBy,jdbcType=INTEGER},
  134 + </if>
  135 + <if test="imageUrl != null">
  136 + image_url = #{imageUrl,jdbcType=VARCHAR},
  137 + </if>
  138 + <if test="createTime != null">
  139 + create_time = #{createTime,jdbcType=INTEGER},
  140 + </if>
  141 + <if test="updateTime != null">
  142 + update_time = #{updateTime,jdbcType=INTEGER},
  143 + </if>
  144 + <if test="status != null">
  145 + status = #{status,jdbcType=TINYINT},
  146 + </if>
  147 + </set>
  148 + where id = #{id,jdbcType=INTEGER}
  149 + </update>
  150 + <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
  151 + update product_cover_activity
  152 + set product_skn = #{productSkn,jdbcType=INTEGER},
  153 + begin_time = #{beginTime,jdbcType=INTEGER},
  154 + end_time = #{endTime,jdbcType=INTEGER},
  155 + content_one = #{contentOne,jdbcType=VARCHAR},
  156 + content_two = #{contentTwo,jdbcType=VARCHAR},
  157 + order_by = #{orderBy,jdbcType=INTEGER},
  158 + image_url = #{imageUrl,jdbcType=VARCHAR},
  159 + create_time = #{createTime,jdbcType=INTEGER},
  160 + update_time = #{updateTime,jdbcType=INTEGER},
  161 + status = #{status,jdbcType=TINYINT}
  162 + where id = #{id,jdbcType=INTEGER}
  163 + </update>
  164 + <select id="selectCount" resultType="java.lang.Integer" timeout="20000">
  165 + SELECT count(*) FROM product_cover_activity
  166 + </select>
  167 + <select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
  168 + select
  169 + <include refid="Base_Column_List"/>
  170 + from product_cover_activity limit #{offset},#{pageSize}
  171 + </select>
  172 +</mapper>
  1 +package com.yoho.search.consumer.index.fullbuild;
  2 +
  3 +import com.yoho.search.dal.ProductCoverActivityMapper;
  4 +import com.yoho.search.dal.model.ProductCoverActivity;
  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/9/16
  13 + */
  14 +@Component
  15 +public class ProductCoverActivityIndexBuilder extends IIndexBuilder {
  16 +
  17 + @Autowired
  18 + private ProductCoverActivityMapper productCoverActivityMapper;
  19 +
  20 + @Override
  21 + public int getTotalCount() throws Exception {
  22 + return productCoverActivityMapper.selectCount();
  23 + }
  24 +
  25 + @Override
  26 + public List<?> getPageLists(int offset, int limit) throws Exception {
  27 + return productCoverActivityMapper.selectPageLists(offset, limit);
  28 + }
  29 +
  30 +
  31 + @Override
  32 + public String getId(Object object) {
  33 + return ((ProductCoverActivity) object).getId().toString();
  34 + }
  35 +}
  1 +package com.yoho.search.consumer.index.increment.yh_shops;
  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.consumer.service.daoService.ProductCoverActivityService;
  9 +import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
  10 +import com.yoho.search.dal.model.ProductCoverActivity;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.stereotype.Component;
  13 +
  14 +/**
  15 + * @author wangnan
  16 + * @version 2019/9/16
  17 + */
  18 +@Component
  19 +@SearchMqConsumerListerner(dbName = "yh_shops", tableName = "product_cover_activity")
  20 +public class ProductCoverActivityMqListener extends AbstractMqListener {
  21 +
  22 + @Autowired
  23 + private IYohoIndexService indexService;
  24 + @Autowired
  25 + private ProductCoverActivityService productCoverActivityService;
  26 +
  27 + @Override
  28 + public String getIndexName() {
  29 + return ISearchConstants.INDEX_NAME_PRODUCT_COVER_ACTIVITY;
  30 + }
  31 +
  32 + @Override
  33 + protected void deleteData(String id) throws Exception {
  34 + productCoverActivityService.delete(Integer.valueOf(id));
  35 + indexService.deleteIndexData(this.getIndexName(), id);
  36 + }
  37 +
  38 + @Override
  39 + protected void updateData(JSONObject data) throws Exception {
  40 + ProductCoverActivity productCoverActivity = ConvertUtils.toJavaObject(ProductCoverActivity.class, data);
  41 + if (productCoverActivity == null || productCoverActivity.getId() == null) {
  42 + return;
  43 + }
  44 + productCoverActivityService.saveOrUpdate(productCoverActivity);
  45 + String idValue = productCoverActivity.getId().toString();
  46 + indexService.updateIndexData(this.getIndexName(), idValue, productCoverActivity);
  47 + }
  48 +
  49 +}
@@ -99,7 +99,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware { @@ -99,7 +99,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
99 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_ZERO_HELP_PRODUCT); 99 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_ZERO_HELP_PRODUCT);
100 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_KEYWORD_CONFIG); 100 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_KEYWORD_CONFIG);
101 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_FIELD_BOOST_CONFIG); 101 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_FIELD_BOOST_CONFIG);
102 - 102 + this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_COVER_ACTIVITY);
103 //重建pi 103 //重建pi
104 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX); 104 this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
105 logger.info("executeYohoIndex end----[end={}][cost={}]", System.currentTimeMillis(), (System.currentTimeMillis() - begin)); 105 logger.info("executeYohoIndex end----[end={}][cost={}]", System.currentTimeMillis(), (System.currentTimeMillis() - begin));
  1 +{
  2 + "productcoveractivity": {
  3 + "_all": {
  4 + "enabled": false
  5 + },
  6 + "_source": {
  7 + "enabled": true
  8 + },
  9 + "properties": {
  10 + "id": {
  11 + "type": "integer"
  12 + },
  13 + "productSkn": {
  14 + "type": "integer"
  15 + },
  16 + "beginTime": {
  17 + "type": "integer"
  18 + },
  19 + "endTime": {
  20 + "type": "integer"
  21 + },
  22 + "contentOne": {
  23 + "type": "keyword"
  24 + },
  25 + "contentTwo": {
  26 + "type": "keyword"
  27 + },
  28 + "orderBy": {
  29 + "type": "integer"
  30 + },
  31 + "imageUrl": {
  32 + "type": "keyword"
  33 + },
  34 + "createTime": {
  35 + "type": "integer"
  36 + },
  37 + "updateTime": {
  38 + "type": "integer"
  39 + },
  40 + "status": {
  41 + "type": "integer"
  42 + }
  43 + }
  44 + }
  45 +}
  1 +package com.yoho.search.consumer.service.daoService;
  2 +
  3 +import com.yoho.search.dal.ProductCoverActivityMapper;
  4 +import com.yoho.search.dal.model.ProductCoverActivity;
  5 +import org.springframework.beans.factory.annotation.Autowired;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +/**
  9 + * @author wangnan
  10 + * @version 2019/9/16
  11 + */
  12 +@Component
  13 +public class ProductCoverActivityService {
  14 +
  15 + @Autowired
  16 + private ProductCoverActivityMapper productCoverActivityMapper;
  17 +
  18 + public ProductCoverActivity getById(Integer id) {
  19 + return productCoverActivityMapper.selectByPrimaryKey(id);
  20 + }
  21 +
  22 + public int insert(ProductCoverActivity productCoverActivity) {
  23 + return productCoverActivityMapper.insert(productCoverActivity);
  24 + }
  25 +
  26 + public int update(ProductCoverActivity productCoverActivity) {
  27 + return productCoverActivityMapper.updateByPrimaryKeySelective(productCoverActivity);
  28 + }
  29 +
  30 + public int saveOrUpdate(ProductCoverActivity productCoverActivity) {
  31 + if (productCoverActivity.getId() == null || productCoverActivityMapper.selectByPrimaryKey(productCoverActivity.getId()) == null) {
  32 + return productCoverActivityMapper.insert(productCoverActivity);
  33 + } else {
  34 + return productCoverActivityMapper.updateByPrimaryKeySelective(productCoverActivity);
  35 + }
  36 + }
  37 +
  38 + public int delete(Integer id) {
  39 + return productCoverActivityMapper.deleteByPrimaryKey(id);
  40 + }
  41 +}
@@ -794,5 +794,19 @@ @@ -794,5 +794,19 @@
794 <rebuildPageSize>2500</rebuildPageSize> 794 <rebuildPageSize>2500</rebuildPageSize>
795 </index> 795 </index>
796 796
  797 + <index>
  798 + <name>productcoveractivity</name>
  799 + <properties>
  800 + <property key="number_of_shards" value="1"/>
  801 + <property key="number_of_replicas" value="auto"/>
  802 + <property key="refresh_interval" value="10s"/>
  803 + <property key="translog.flush_threshold_size" value="100mb"/>
  804 + </properties>
  805 + <builderClass>com.yoho.search.consumer.index.fullbuild.ProductCoverActivityIndexBuilder</builderClass>
  806 + <mappingFile>esmapping/productcoveractivity.json</mappingFile>
  807 + <analysisFile>analysis/default.yml</analysisFile>
  808 + <rebuildPageSize>2500</rebuildPageSize>
  809 + </index>
  810 +
797 </client> 811 </client>
798 </IndexConfigs> 812 </IndexConfigs>
@@ -798,5 +798,19 @@ @@ -798,5 +798,19 @@
798 <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize> 798 <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
799 </index> 799 </index>
800 800
  801 + <index>
  802 + <name>productcoveractivity</name>
  803 + <properties>
  804 + <property key="number_of_shards" value="1"/>
  805 + <property key="number_of_replicas" value="auto"/>
  806 + <property key="refresh_interval" value="${search.index.refresh_interval}"/>
  807 + <property key="translog.flush_threshold_size" value="${search.index.translog.flush_threshold_size}"/>
  808 + </properties>
  809 + <builderClass>com.yoho.search.consumer.index.fullbuild.ProductCoverActivityIndexBuilder</builderClass>
  810 + <mappingFile>esmapping/productcoveractivity.json</mappingFile>
  811 + <analysisFile>analysis/default.yml</analysisFile>
  812 + <rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
  813 + </index>
  814 +
801 </client> 815 </client>
802 </IndexConfigs> 816 </IndexConfigs>