Authored by wangnan9279

cs_search_resource_ufo

package com.yoho.search.dal;
import com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface CsSearchResourceUfoMapper {
int deleteByPrimaryKey(Integer id);
int insert(CsSearchResourceUfo record);
int insertSelective(CsSearchResourceUfo record);
CsSearchResourceUfo selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(CsSearchResourceUfo record);
int updateByPrimaryKey(CsSearchResourceUfo record);
int selectCount();
List<CsSearchResourceUfo> selectPageLists(@Param(value = "offset") Integer offset, @Param(value = "pageSize") Integer pageSize);
}
\ 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.CsSearchResourceUfoMapper" >
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="image" property="image" jdbcType="VARCHAR" />
<result column="link_url" property="linkUrl" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="order_by" property="orderBy" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, name, image, link_url, status, update_time, order_by
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from cs_search_resource_ufo
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from cs_search_resource_ufo
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo" >
insert into cs_search_resource_ufo (id, name, image,
link_url, status, update_time,
order_by)
values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{image,jdbcType=VARCHAR},
#{linkUrl,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER},
#{orderBy,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo" >
insert into cs_search_resource_ufo
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="image != null" >
image,
</if>
<if test="linkUrl != null" >
link_url,
</if>
<if test="status != null" >
status,
</if>
<if test="updateTime != null" >
update_time,
</if>
<if test="orderBy != null" >
order_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=INTEGER},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="image != null" >
#{image,jdbcType=VARCHAR},
</if>
<if test="linkUrl != null" >
#{linkUrl,jdbcType=VARCHAR},
</if>
<if test="status != null" >
#{status,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
#{updateTime,jdbcType=INTEGER},
</if>
<if test="orderBy != null" >
#{orderBy,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo" >
update cs_search_resource_ufo
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="image != null" >
image = #{image,jdbcType=VARCHAR},
</if>
<if test="linkUrl != null" >
link_url = #{linkUrl,jdbcType=VARCHAR},
</if>
<if test="status != null" >
status = #{status,jdbcType=INTEGER},
</if>
<if test="updateTime != null" >
update_time = #{updateTime,jdbcType=INTEGER},
</if>
<if test="orderBy != null" >
order_by = #{orderBy,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo" >
update cs_search_resource_ufo
set name = #{name,jdbcType=VARCHAR},
image = #{image,jdbcType=VARCHAR},
link_url = #{linkUrl,jdbcType=VARCHAR},
status = #{status,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER},
order_by = #{orderBy,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer" timeout="20000">
SELECT count(1) FROM cs_search_resource_ufo
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List"/>
from cs_search_resource_ufo limit #{offset},#{pageSize}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.fullbuild.ufo;
import com.yoho.search.consumer.index.fullbuild.IIndexBuilder;
import com.yoho.search.dal.CsSearchResourceUfoMapper;
import com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author wangnan
* @version 2019/4/19
*/
@Component
public class CsSearchResourceUfoBuilder extends IIndexBuilder {
@Autowired
private CsSearchResourceUfoMapper csSearchResourceUfoMapper;
@Override
public int getTotalCount() throws Exception {
return csSearchResourceUfoMapper.selectCount();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return csSearchResourceUfoMapper.selectPageLists(offset, limit);
}
@Override
public String getId(Object object) {
return ((CsSearchResourceUfo) 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.CsSearchResourceUfoMapper;
import com.yoho.search.dal.model.ufo_product.CsSearchResourceUfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @author wangnan
* @version 2019/4/19
*/
@Component
@SearchMqConsumerListerner(dbName = "yhb_operations", tableName = "cs_search_resource_ufo")
public class CsSearchResourceUfoMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
@Autowired
private CsSearchResourceUfoMapper csSearchResourceUfoMapper;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE_UFO;
}
@Override
protected void deleteData(String id) throws Exception {
csSearchResourceUfoMapper.deleteByPrimaryKey(Integer.valueOf(id));
indexService.deleteIndexData(this.getIndexName(), id);
}
@Override
protected void updateData(JSONObject data) throws Exception {
CsSearchResourceUfo csSearchResourceUfo = ConvertUtils.toJavaObject(CsSearchResourceUfo.class, data);
if (csSearchResourceUfo == null || csSearchResourceUfo.getId() == null) {
return;
}
if (csSearchResourceUfoMapper.selectByPrimaryKey(csSearchResourceUfo.getId()) == null) {
csSearchResourceUfoMapper.insertSelective(csSearchResourceUfo);
} else {
csSearchResourceUfoMapper.updateByPrimaryKey(csSearchResourceUfo);
}
String idValue = csSearchResourceUfo.getId().toString();
indexService.updateIndexData(this.getIndexName(), idValue, csSearchResourceUfo);
}
}
... ...
... ... @@ -95,6 +95,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_SEARCH_LABLE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SALES_CATEGORY_SEARCH_LABLE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_CS_SEARCH_RESOURCE_UFO);
//最后重建pi
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PRODUCT_INDEX);
... ...
{
"cssearchresourceufo": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"id": {
"type": "integer"
},
"name": {
"type": "keyword"
},
"image": {
"type": "keyword"
},
"linkUrl": {
"type": "keyword"
},
"status": {
"type": "integer"
},
"updateTime": {
"type": "integer"
},
"orderBy": {
"type": "integer"
}
}
}
}
\ No newline at end of file
... ...
... ... @@ -12,30 +12,30 @@ import org.springframework.stereotype.Component;
@Component
public class UfoProductService {
@Autowired
private UfoProductMapper sizeMapper;
private UfoProductMapper ufoProductMapper;
public Product getById(Integer id) {
return sizeMapper.selectByPrimaryKey(id);
return ufoProductMapper.selectByPrimaryKey(id);
}
public int insert(Product size) {
return sizeMapper.insertSelective(size);
return ufoProductMapper.insertSelective(size);
}
public int update(Product size) {
return sizeMapper.updateByPrimaryKey(size);
return ufoProductMapper.updateByPrimaryKey(size);
}
public int saveOrUpdate(Product size) {
if (size.getId() == null || sizeMapper.selectByPrimaryKey(size.getId()) == null) {
return sizeMapper.insertSelective(size);
if (size.getId() == null || ufoProductMapper.selectByPrimaryKey(size.getId()) == null) {
return ufoProductMapper.insertSelective(size);
} else {
return sizeMapper.updateByPrimaryKey(size);
return ufoProductMapper.updateByPrimaryKey(size);
}
}
public int delete(Integer id) {
return sizeMapper.deleteByPrimaryKey(id);
return ufoProductMapper.deleteByPrimaryKey(id);
}
}
... ...
... ... @@ -45,6 +45,8 @@ datasources:
- com.yoho.search.dal.ProductRecommendMapper
- com.yoho.search.dal.BigdataUfoRankMapper
- com.yoho.search.dal.BigdataUfoRankBMapper
- com.yoho.search.dal.CsSearchResourceUfoMapper
readOnlyInSlave: true
... ...
... ... @@ -696,5 +696,19 @@
<rebuildPageSize>2500</rebuildPageSize>
</index>
<index>
<name>cssearchresourceufo</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.ufo.CsSearchResourceUfoBuilder</builderClass>
<mappingFile>esmapping/cssearchresourceufo.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -45,5 +45,6 @@ datasources:
- com.yoho.search.dal.ProductRecommendMapper
- com.yoho.search.dal.BigdataUfoRankMapper
- com.yoho.search.dal.BigdataUfoRankBMapper
- com.yoho.search.dal.CsSearchResourceUfoMapper
readOnlyInSlave: ${readOnlyInSlave}
\ No newline at end of file
... ...
... ... @@ -700,5 +700,19 @@
<rebuildPageSize>2500</rebuildPageSize>
</index>
<index>
<name>cssearchresourceufo</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.ufo.CsSearchResourceUfoBuilder</builderClass>
<mappingFile>esmapping/cssearchresourceufo.json</mappingFile>
<analysisFile>analysis/default.yml</analysisFile>
<rebuildPageSize>2500</rebuildPageSize>
</index>
</client>
</IndexConfigs>
... ...