Authored by wangnan9279

CsSearchRankConfig

package com.yoho.search.dal;
import com.yoho.search.dal.model.CsSearchRankConfig;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CsSearchRankConfigMapper {
int deleteByPrimaryKey(Integer id);
int insert(CsSearchRankConfig record);
int insertSelective(CsSearchRankConfig record);
CsSearchRankConfig selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(CsSearchRankConfig record);
int updateByPrimaryKey(CsSearchRankConfig record);
int selectCount();
List<CsSearchRankConfig> selectPageLists(@Param(value = "start") Integer start, @Param(value = "limit") Integer limit);
}
\ 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.CsSearchRankConfigMapper" >
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.CsSearchRankConfig" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="skn" property="skn" jdbcType="INTEGER" />
<result column="rank" property="rank" jdbcType="INTEGER" />
<result column="sale_num" property="saleNum" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, skn, rank, sale_num, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from cs_search_rank_config
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from cs_search_rank_config
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" >
insert into cs_search_rank_config (id, skn, rank,
sale_num, update_time)
values (#{id,jdbcType=INTEGER}, #{skn,jdbcType=INTEGER}, #{rank,jdbcType=INTEGER},
#{saleNum,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" >
insert into cs_search_rank_config
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="skn != null" >
skn,
</if>
<if test="rank != null" >
rank,
</if>
<if test="saleNum != null" >
sale_num,
</if>
<if test="updateTime != null" >
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="skn != null" >
#{skn,jdbcType=INTEGER},
</if>
<if test="rank != null" >
#{rank,jdbcType=INTEGER},
</if>
<if test="saleNum != null" >
#{saleNum,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" >
update cs_search_rank_config
<set >
<if test="skn != null" >
skn = #{skn,jdbcType=INTEGER},
</if>
<if test="rank != null" >
rank = #{rank,jdbcType=INTEGER},
</if>
<if test="saleNum != null" >
sale_num = #{saleNum,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.CsSearchRankConfig" >
update cs_search_rank_config
set skn = #{skn,jdbcType=INTEGER},
rank = #{rank,jdbcType=INTEGER},
sale_num = #{saleNum,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="int">
select count(0) from cs_search_rank_config
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List"/>
from cs_search_rank_config limit #{start}, #{limit}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.dal.CsSearchRankConfigMapper;
import com.yoho.search.dal.model.CsSearchRankConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author wangnan
* @version 2019/5/8
*/
@Component
public class CsSearchRankConfigIndexBuilder extends IIndexBuilder {
@Autowired
private CsSearchRankConfigMapper csSearchRankConfigMapper;
@Override
public int getTotalCount() throws Exception {
return csSearchRankConfigMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return csSearchRankConfigMapper.selectPageLists(offset, limit);
}
@Override
public String getId(Object object) {
return ((CsSearchRankConfig) object).getId().toString();
}
}
... ...
package com.yoho.search.consumer.index.increment.yhb_operations;
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.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.CsSearchRankConfigMapper;
import com.yoho.search.dal.model.CsSearchRankConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wangnan
* @version 2019/5/8
*/
@Component
@SearchMqConsumerListerner(dbName = "yhb_operations", tableName = "cs_search_rank_config")
public class CsSearchRankConfigMqListener extends AbstractMqListener {
@Autowired
private CsSearchRankConfigMapper csSearchRankConfigMapper;
@Autowired
private IYohoIndexService indexService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_CS_SEARCH_RANK_CONFIG;
}
@Override
protected void deleteData(String id) throws Exception {
csSearchRankConfigMapper.deleteByPrimaryKey(Integer.valueOf(id));
indexService.deleteIndexData(this.getIndexName(), id);
}
@Override
protected void updateData(JSONObject data) throws Exception {
CsSearchRankConfig csSearchRankConfig = ConvertUtils.toJavaObject(CsSearchRankConfig.class, data);
if (csSearchRankConfig == null || csSearchRankConfig.getId() == null) {
return;
}
this.saveOrUpdate(csSearchRankConfig);
indexService.updateIndexData(this.getIndexName(), csSearchRankConfig.getId().toString(), csSearchRankConfig);
}
private int saveOrUpdate(CsSearchRankConfig csSearchRankConfig) {
if (csSearchRankConfig.getId() == null || csSearchRankConfigMapper.selectByPrimaryKey(csSearchRankConfig.getId()) == null) {
return csSearchRankConfigMapper.insertSelective(csSearchRankConfig);
} else {
return csSearchRankConfigMapper.updateByPrimaryKeySelective(csSearchRankConfig);
}
}
}
... ...
... ... @@ -94,6 +94,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SALES_CATEGORY_SEARCH_LABLE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_POOL);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RANK_CONFIG);
//重建pi
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
... ...
{
"cssearchrankconfig": {
"_all":{
"enabled":false
},
"_source":{
"enabled":true
},
"properties": {
"id": {
"type": "integer"
},
"skn": {
"type": "integer"
},
"rank": {
"type": "integer"
},
"saleNum": {
"type": "integer"
},
"updateTime": {
"type": "integer"
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -710,5 +710,19 @@
<rebuildPageSize>2500</rebuildPageSize>
</index>
<index>
<name>cssearchrankconfig</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.CsSearchRankConfigIndexBuilder</builderClass>
<mappingFile>esmapping/cssearchrankconfig.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -714,5 +714,19 @@
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
<index>
<name>cssearchrankconfig</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.CsSearchRankConfigIndexBuilder</builderClass>
<mappingFile>esmapping/cssearchrankconfig.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>${search.index.batch.limit}</rebuildPageSize>
</index>
</client>
</IndexConfigs>
... ...