Authored by wangnan9279

图库

package com.yoho.search.dal;
import com.yoho.search.dal.model.ImageRepertory;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ImageRepertoryMapper {
int deleteByPrimaryKey(Integer id);
int insert(ImageRepertory record);
int insertSelective(ImageRepertory record);
ImageRepertory selectByPrimaryKey(Integer id);
int updateByPrimaryKeySelective(ImageRepertory record);
int updateByPrimaryKey(ImageRepertory record);
List<ImageRepertory> 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.ImageRepertoryMapper">
<resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ImageRepertory">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="item_id" property="itemId" jdbcType="INTEGER"/>
<result column="channel" property="channel" jdbcType="INTEGER"/>
<result column="season" property="season" jdbcType="INTEGER"/>
<result column="image_url" property="imageUrl" jdbcType="VARCHAR"/>
<result column="image_size" property="imageSize" jdbcType="VARCHAR"/>
<result column="image_name" property="imageName" jdbcType="VARCHAR"/>
<result column="image_type" property="imageType" jdbcType="INTEGER"/>
<result column="item_type" property="itemType" jdbcType="INTEGER"/>
<result column="remarks" property="remarks" jdbcType="VARCHAR"/>
<result column="port" property="port" jdbcType="INTEGER"/>
<result column="menu" property="menu" jdbcType="VARCHAR"/>
<result column="menu_name" property="menuName" jdbcType="VARCHAR"/>
<result column="create_time" property="createTime" jdbcType="INTEGER"/>
<result column="update_time" property="updateTime" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, item_id, channel, season, image_url, image_size, image_name, image_type, item_type,
remarks, port, menu, menu_name, create_time, update_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from image_repertory
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from image_repertory
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yoho.search.dal.model.ImageRepertory">
insert into image_repertory (id, item_id, channel,
season, image_url, image_size,
image_name, image_type, item_type,
remarks, port, menu,
menu_name, create_time, update_time
)
values (#{id,jdbcType=INTEGER}, #{itemId,jdbcType=INTEGER}, #{channel,jdbcType=INTEGER},
#{season,jdbcType=INTEGER}, #{imageUrl,jdbcType=VARCHAR}, #{imageSize,jdbcType=VARCHAR},
#{imageName,jdbcType=VARCHAR}, #{imageType,jdbcType=INTEGER}, #{itemType,jdbcType=INTEGER},
#{remarks,jdbcType=VARCHAR}, #{port,jdbcType=INTEGER}, #{menu,jdbcType=VARCHAR},
#{menuName,jdbcType=VARCHAR}, #{createTime,jdbcType=INTEGER}, #{updateTime,jdbcType=INTEGER}
)
</insert>
<insert id="insertSelective" parameterType="com.yoho.search.dal.model.ImageRepertory">
insert into image_repertory
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="itemId != null">
item_id,
</if>
<if test="channel != null">
channel,
</if>
<if test="season != null">
season,
</if>
<if test="imageUrl != null">
image_url,
</if>
<if test="imageSize != null">
image_size,
</if>
<if test="imageName != null">
image_name,
</if>
<if test="imageType != null">
image_type,
</if>
<if test="itemType != null">
item_type,
</if>
<if test="remarks != null">
remarks,
</if>
<if test="port != null">
port,
</if>
<if test="menu != null">
menu,
</if>
<if test="menuName != null">
menu_name,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="itemId != null">
#{itemId,jdbcType=INTEGER},
</if>
<if test="channel != null">
#{channel,jdbcType=INTEGER},
</if>
<if test="season != null">
#{season,jdbcType=INTEGER},
</if>
<if test="imageUrl != null">
#{imageUrl,jdbcType=VARCHAR},
</if>
<if test="imageSize != null">
#{imageSize,jdbcType=VARCHAR},
</if>
<if test="imageName != null">
#{imageName,jdbcType=VARCHAR},
</if>
<if test="imageType != null">
#{imageType,jdbcType=INTEGER},
</if>
<if test="itemType != null">
#{itemType,jdbcType=INTEGER},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="port != null">
#{port,jdbcType=INTEGER},
</if>
<if test="menu != null">
#{menu,jdbcType=VARCHAR},
</if>
<if test="menuName != null">
#{menuName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.ImageRepertory">
update image_repertory
<set>
<if test="itemId != null">
item_id = #{itemId,jdbcType=INTEGER},
</if>
<if test="channel != null">
channel = #{channel,jdbcType=INTEGER},
</if>
<if test="season != null">
season = #{season,jdbcType=INTEGER},
</if>
<if test="imageUrl != null">
image_url = #{imageUrl,jdbcType=VARCHAR},
</if>
<if test="imageSize != null">
image_size = #{imageSize,jdbcType=VARCHAR},
</if>
<if test="imageName != null">
image_name = #{imageName,jdbcType=VARCHAR},
</if>
<if test="imageType != null">
image_type = #{imageType,jdbcType=INTEGER},
</if>
<if test="itemType != null">
item_type = #{itemType,jdbcType=INTEGER},
</if>
<if test="remarks != null">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="port != null">
port = #{port,jdbcType=INTEGER},
</if>
<if test="menu != null">
menu = #{menu,jdbcType=VARCHAR},
</if>
<if test="menuName != null">
menu_name = #{menuName,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,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.ImageRepertory">
update image_repertory
set item_id = #{itemId,jdbcType=INTEGER},
channel = #{channel,jdbcType=INTEGER},
season = #{season,jdbcType=INTEGER},
image_url = #{imageUrl,jdbcType=VARCHAR},
image_size = #{imageSize,jdbcType=VARCHAR},
image_name = #{imageName,jdbcType=VARCHAR},
image_type = #{imageType,jdbcType=INTEGER},
item_type = #{itemType,jdbcType=INTEGER},
remarks = #{remarks,jdbcType=VARCHAR},
port = #{port,jdbcType=INTEGER},
menu = #{menu,jdbcType=VARCHAR},
menu_name = #{menuName,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectCount" resultType="java.lang.Integer" timeout="20000">
SELECT count(id) FROM image_repertory
</select>
<select id="selectPageLists" resultMap="BaseResultMap" timeout="20000">
select
<include refid="Base_Column_List"/>
from image_repertory limit #{offset},#{pageSize}
</select>
</mapper>
\ No newline at end of file
... ...
package com.yoho.search.consumer.index.fullbuild;
import com.yoho.search.consumer.index.common.IIndexBuilder;
import com.yoho.search.consumer.service.daoService.ImageRepertoryService;
import com.yoho.search.dal.model.ImageRepertory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @Author: wangnan
* @Date: Created in 2018/4/16
*/
@Component
public class ImageRepertoryIndexBuilder extends IIndexBuilder {
@Autowired
private ImageRepertoryService imageRepertoryService;
@Override
public int getTotalCount() throws Exception {
return imageRepertoryService.count();
}
@Override
public List<?> getPageLists(int offset, int limit) throws Exception {
return imageRepertoryService.getPageLists(offset, limit);
}
@Override
public String getId(Object object) {
return ((ImageRepertory) object).getId().toString();
}
}
... ...
package com.yoho.search.consumer.index.increment.otherIndex;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ConvertUtils;
import com.yoho.search.base.utils.EventReportEnum;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.consumer.index.common.IYohoIndexService;
import com.yoho.search.consumer.index.increment.AbstractMqListener;
import com.yoho.search.consumer.service.daoService.ImageRepertoryService;
import com.yoho.search.core.message.beans.SearchMqConsumerListerner;
import com.yoho.search.dal.model.ImageRepertory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* @Author: wangnan
* @Date: Created in 2018/4/16
*/
@Component
@SearchMqConsumerListerner(tableName = "image_repertory")
public class ImageRepertoryMqListener extends AbstractMqListener {
@Autowired
private IYohoIndexService indexService;
@Autowired
private ImageRepertoryService imageRepertoryService;
@Override
public String getIndexName() {
return ISearchConstants.INDEX_NAME_IMAGE_REPERTORY;
}
@Override
protected EventReportEnum getEventReportEnum() {
return EventReportEnum.IMAGEREPERTORYMQLISTENER_ONMESSAGE;
}
@Override
protected void deleteData(String id) throws Exception {
imageRepertoryService.delete(Integer.valueOf(id));
indexService.deleteIndexData(this.getIndexName(), id);
}
@Override
protected void updateData(JSONObject data) throws Exception {
ImageRepertory imageRepertory = ConvertUtils.toJavaObject(ImageRepertory.class, data);
if (imageRepertory == null || imageRepertory.getId() == null) {
return;
}
imageRepertoryService.saveOrUpdate(imageRepertory);
String idValue = imageRepertory.getId().toString();
indexService.updateIndexData(this.getIndexName(), idValue, imageRepertory);
}
}
... ...
... ... @@ -53,6 +53,7 @@ public class IndexRebuildJob implements ApplicationEventPublisherAware {
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_SHOPS);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_ZQ_NAME);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_PROMOTIONTYPE);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_IMAGE_REPERTORY);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_IMAGE_VECTORS);
this.rebuildIndexWithlog(ISearchConstants.INDEX_NAME_BIGDATA_SIMILAR_SKN_INDEX);
... ...
index.analysis.analyzer.default.type: keyword
\ No newline at end of file
... ...
{
"imagerepertory": {
"_all": {
"enabled": false
},
"_source": {
"enabled": true
},
"properties": {
"id": {
"type": "integer"
},
"itemId": {
"type": "integer"
},
"channel": {
"type": "integer"
},
"season": {
"type": "integer"
},
"imageUrl": {
"type": "keyword"
},
"imageSize": {
"type": "keyword"
},
"imageName": {
"type": "keyword"
},
"imageType": {
"type": "integer"
},
"itemType": {
"type": "integer"
},
"remarks": {
"type": "keyword"
},
"port": {
"type": "integer"
},
"menu": {
"type": "keyword"
},
"menuName": {
"type": "keyword"
},
"createTime": {
"type": "integer"
},
"updateTime": {
"type": "integer"
}
}
}
}
\ No newline at end of file
... ...
package com.yoho.search.consumer.service.daoService;
import com.yoho.search.dal.ImageRepertoryMapper;
import com.yoho.search.dal.model.ImageRepertory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: wangnan
* @Date: Created in 2018/4/16
*/
@Service
public class ImageRepertoryService {
@Autowired
private ImageRepertoryMapper imageRepertoryMapper;
public ImageRepertory getById(Integer id) {
return imageRepertoryMapper.selectByPrimaryKey(id);
}
public int insert(ImageRepertory ImageRepertory) {
return imageRepertoryMapper.insert(ImageRepertory);
}
public int update(ImageRepertory ImageRepertory) {
return imageRepertoryMapper.updateByPrimaryKeySelective(ImageRepertory);
}
public int saveOrUpdate(ImageRepertory ImageRepertory) {
if (ImageRepertory.getId() == null || imageRepertoryMapper.selectByPrimaryKey(ImageRepertory.getId()) == null) {
return imageRepertoryMapper.insert(ImageRepertory);
} else {
return imageRepertoryMapper.updateByPrimaryKeySelective(ImageRepertory);
}
}
public int delete(Integer id) {
return imageRepertoryMapper.deleteByPrimaryKey(id);
}
public List<ImageRepertory> getPageLists(int start, int limit) {
return imageRepertoryMapper.selectPageLists(start, limit);
}
public int count() {
return imageRepertoryMapper.selectCount();
}
}
... ...
... ... @@ -335,5 +335,18 @@
<analysisFile>analysis/bigdatabrandvectorw2v.yml</analysisFile>
</index>
<index>
<name>imagerepertory</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="0"/>
<property key="refresh_interval" value="10s"/>
<property key="translog.flush_threshold_size" value="100mb"/>
</properties>
<builderClass>com.yoho.search.consumer.index.fullbuild.ImageRepertoryIndexBuilder</builderClass>
<mappingFile>esmapping/imagerepertory.json</mappingFile>
<analysisFile>analysis/imagerepertory.yml</analysisFile>
</index>
</client>
</IndexConfigs>
\ No newline at end of file
... ...
... ... @@ -321,18 +321,20 @@
<analysisFile>analysis/bigdatabrandvector.yml</analysisFile>
</index>
<index>
<name>bigdatabrandvectorw2v</name>
<name>imagerepertory</name>
<properties>
<property key="number_of_shards" value="1"/>
<property key="number_of_replicas" value="${search.index.number_of_replicas}"/>
<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.BigdataBrandVectorW2vIndexBuilder</builderClass>
<mappingFile>esmapping/bigdatabrandvectorw2v.json</mappingFile>
<analysisFile>analysis/bigdatabrandvectorw2v.yml</analysisFile>
<builderClass>com.yoho.search.consumer.index.fullbuild.ImageRepertoryIndexBuilder</builderClass>
<mappingFile>esmapping/imagerepertory.json</mappingFile>
<analysisFile>analysis/imagerepertory.yml</analysisFile>
</index>
</client>
</IndexConfigs>
... ...