Authored by wangnan9279

Merge branch '0930' into 1010

package com.yoho.search.dal;
import com.yoho.search.dal.model.ProductCoverActivity;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ProductCoverActivityMapper {
int deleteByPrimaryKey(Integer id);
int insert(ProductCoverActivity record);
int insertSelective(ProductCoverActivity record);
ProductCoverActivity selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ProductCoverActivity record);
int updateByPrimaryKey(ProductCoverActivity record);
List<ProductCoverActivity> selectPageLists(@Param(value="offset")Integer offset, @Param(value="pageSize")Integer pageSize);
int selectCount();
}
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.yoho.search.dal.ProductCoverActivityMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductCoverActivity">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="product_skn" property="productSkn" jdbcType="INTEGER"/>
<result column="begin_time" property="beginTime" jdbcType="INTEGER"/>
<result column="end_time" property="endTime" jdbcType="INTEGER"/>
<result column="content_one" property="contentOne" jdbcType="VARCHAR"/>
<result column="content_two" property="contentTwo" jdbcType="VARCHAR"/>
<result column="order_by" property="orderBy" jdbcType="INTEGER"/>
<result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
<result column="status" property="status" jdbcType="TINYINT"/>
</resultMap>
<sql id="Base_Column_List">
id, product_skn, begin_time, end_time, content_one, content_two, order_by, image_url,
create_time, update_time, status
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from product_cover_activity
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from product_cover_activity
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
insert into product_cover_activity (id, product_skn, begin_time,
end_time, content_one, content_two,
order_by, image_url, create_time,
update_time, status)
values (#{id,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{beginTime,jdbcType=INTEGER},
#{endTime,jdbcType=INTEGER}, #{contentOne,jdbcType=VARCHAR}, #{contentTwo,jdbcType=VARCHAR},
#{orderBy,jdbcType=INTEGER}, #{imageUrl,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER},
#{updateTime,jdbcType=INTEGER}, #{status,jdbcType=TINYINT})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
insert into product_cover_activity
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="productSkn != null">
product_skn,
</if>
<if test="beginTime != null">
begin_time,
</if>
<if test="endTime != null">
end_time,
</if>
<if test="contentOne != null">
content_one,
</if>
<if test="contentTwo != null">
content_two,
</if>
<if test="orderBy != null">
order_by,
</if>
<if test="imageUrl != null">
image_url,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="status != null">
status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="productSkn != null">
#{productSkn,jdbcType=INTEGER},
</if>
<if test="beginTime != null">
#{beginTime,jdbcType=INTEGER},
</if>
<if test="endTime != null">
#{endTime,jdbcType=INTEGER},
</if>
<if test="contentOne != null">
#{contentOne,jdbcType=VARCHAR},
</if>
<if test="contentTwo != null">
#{contentTwo,jdbcType=VARCHAR},
</if>
<if test="orderBy != null">
#{orderBy,jdbcType=INTEGER},
</if>
<if test="imageUrl != null">
#{imageUrl,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=INTEGER},
</if>
<if test="status != null">
#{status,jdbcType=TINYINT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
update product_cover_activity
<set>
<if test="productSkn != null">
product_skn = #{productSkn,jdbcType=INTEGER},
</if>
<if test="beginTime != null">
begin_time = #{beginTime,jdbcType=INTEGER},
</if>
<if test="endTime != null">
end_time = #{endTime,jdbcType=INTEGER},
</if>
<if test="contentOne != null">
content_one = #{contentOne,jdbcType=VARCHAR},
</if>
<if test="contentTwo != null">
content_two = #{contentTwo,jdbcType=VARCHAR},
</if>
<if test="orderBy != null">
order_by = #{orderBy,jdbcType=INTEGER},
</if>
<if test="imageUrl != null">
image_url = #{imageUrl,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="status != null">
status = #{status,jdbcType=TINYINT},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ProductCoverActivity">
update product_cover_activity
set product_skn = #{productSkn,jdbcType=INTEGER},
begin_time = #{beginTime,jdbcType=INTEGER},
end_time = #{endTime,jdbcType=INTEGER},
content_one = #{contentOne,jdbcType=VARCHAR},
content_two = #{contentTwo,jdbcType=VARCHAR},
order_by = #{orderBy,jdbcType=INTEGER},
image_url = #{imageUrl,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
status = #{status,jdbcType=TINYINT}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer" timeout="20000">
SELECT count(*) FROM product_cover_activity
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List"/>
from product_cover_activity limit #{offset},#{pageSize}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.dal.ProductCoverActivityMapper;
import com.yoho.search.dal.model.ProductCoverActivity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author wangnan
* @version 2019/9/16
*/
@Component
public class ProductCoverActivityIndexBuilder extends IIndexBuilder {
@Autowired
private ProductCoverActivityMapper productCoverActivityMapper;
@Override
public int getTotalCount() throws Exception {
return productCoverActivityMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return productCoverActivityMapper.selectPageLists(offset, limit);
}
@Override
public String getId(Object object) {
return ((ProductCoverActivity) object).getId().toString();
}
}
... ...
package com.yoho.search.consumer.index.increment.yh_shops;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ConvertUtils;
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.ProductCoverActivityService;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.ProductCoverActivity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wangnan
* @version 2019/9/16
*/
@Component
@SearchMqConsumerListerner(dbName = "yh_shops", tableName = "product_cover_activity")
public class ProductCoverActivityMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
@Autowired
private ProductCoverActivityService productCoverActivityService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_PRODUCT_COVER_ACTIVITY;
}
@Override
protected void deleteData(String id) throws Exception {
productCoverActivityService.delete(Integer.valueOf(id));
indexService.deleteIndexData(this.getIndexName(), id);
}
@Override
protected void updateData(JSONObject data) throws Exception {
ProductCoverActivity productCoverActivity = ConvertUtils.toJavaObject(ProductCoverActivity.class, data);
if (productCoverActivity == null || productCoverActivity.getId() == null) {
return;
}
productCoverActivityService.saveOrUpdate(productCoverActivity);
String idValue = productCoverActivity.getId().toString();
indexService.updateIndexData(this.getIndexName(), idValue, productCoverActivity);
}
}
... ...
... ... @@ -99,7 +99,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_ZERO_HELP_PRODUCT);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_KEYWORD_CONFIG);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_FIELD_BOOST_CONFIG);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_COVER_ACTIVITY);
//重建pi
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
logger.info("executeYohoIndex end----[end={}][cost={}]", System.currentTimeMillis(), (System.currentTimeMillis() - begin));
... ...
{
"productcoveractivity": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"id": {
"type": "integer"
},
"productSkn": {
"type": "integer"
},
"beginTime": {
"type": "integer"
},
"endTime": {
"type": "integer"
},
"contentOne": {
"type": "keyword"
},
"contentTwo": {
"type": "keyword"
},
"orderBy": {
"type": "integer"
},
"imageUrl": {
"type": "keyword"
},
"createTime": {
"type": "integer"
},
"updateTime": {
"type": "integer"
},
"status": {
"type": "integer"
}
}
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.daoService;
import com.yoho.search.dal.ProductCoverActivityMapper;
import com.yoho.search.dal.model.ProductCoverActivity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wangnan
* @version 2019/9/16
*/
@Component
public class ProductCoverActivityService {
@Autowired
private ProductCoverActivityMapper productCoverActivityMapper;
public ProductCoverActivity getById(Integer id) {
return productCoverActivityMapper.selectByPrimaryKey(id);
}
public int insert(ProductCoverActivity productCoverActivity) {
return productCoverActivityMapper.insert(productCoverActivity);
}
public int update(ProductCoverActivity productCoverActivity) {
return productCoverActivityMapper.updateByPrimaryKeySelective(productCoverActivity);
}
public int saveOrUpdate(ProductCoverActivity productCoverActivity) {
if (productCoverActivity.getId() == null || productCoverActivityMapper.selectByPrimaryKey(productCoverActivity.getId()) == null) {
return productCoverActivityMapper.insert(productCoverActivity);
} else {
return productCoverActivityMapper.updateByPrimaryKeySelective(productCoverActivity);
}
}
public int delete(Integer id) {
return productCoverActivityMapper.deleteByPrimaryKey(id);
}
}
... ...
... ... @@ -794,5 +794,19 @@
<rebuildPageSize>2500</rebuildPageSize>
</index>
<index>
<name>productcoveractivity</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.ProductCoverActivityIndexBuilder</builderClass>
<mappingFile>esmapping/productcoveractivity.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -798,5 +798,19 @@
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
<name>productcoveractivity</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.ProductCoverActivityIndexBuilder</builderClass>
<mappingFile>esmapping/productcoveractivity.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
</client>
</IndexConfigs>
... ...