ProductVectorFeatureMapper.xml 2.68 KB
<?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.ProductVectorFeatureMapper">
    <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductVectorFeature">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="product_skn" property="productSkn" jdbcType="INTEGER"/>
        <result column="generate_date" property="generateDate" jdbcType="VARCHAR"/>
        <result column="feature_value" property="featureValue" jdbcType="VARCHAR"/>
    </resultMap>

    <resultMap id="MonitorResultMap" type="com.yoho.search.dal.model.BigdataMonitor">
        <result column="generate_date" property="dateId" jdbcType="VARCHAR"/>
        <result column="num" property="num" jdbcType="INTEGER"/>
    </resultMap>
    <sql id="Base_Column_List">
		id, product_skn, generate_date, feature_value
	</sql>

    <select id="selectCount" resultType="java.lang.Integer" timeout="20000">
		SELECT count(1) FROM product_vector_feature where generate_date = #{generateDate,jdbcType=VARCHAR}
	</select>

    <select id="selectByGenerateDate" resultType="java.lang.Long" timeout="20000">
        SELECT id FROM product_vector_feature where generate_date = #{generateDate,jdbcType=VARCHAR} limit #{pageSize}
    </select>

    <select id="selectBySkns" resultMap="BaseResultMap" timeout="20000">
        select
        <include refid="Base_Column_List"/>
        from product_vector_feature where generate_date = #{generateDate,jdbcType=VARCHAR}
        and product_skn in
        <foreach item="item" index="index" collection="list" open="("
                 separator="," close=")">
            #{item}
        </foreach>
    </select>

    <insert id="insertBatch" parameterType="java.util.List" timeout="20000">
        insert ignore into product_vector_feature (product_skn, generate_date, feature_value)
        values
        <foreach collection="list" item="item" index="index"
                 separator=",">
            (#{item.productSkn, jdbcType=INTEGER},
            #{item.generate_date, jdbcType=VARCHAR},
            #{item.feature_value, jdbcType=VARCHAR})
        </foreach>
    </insert>

    <delete id="deleteBatch" parameterType="java.util.List">
        DELETE FROM product_vector_feature WHERE ID in
        <foreach item="item" index="index" collection="list" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <select id="selectCountGroupByDateId" resultMap="MonitorResultMap">
        SELECT generate_date, count(*) num FROM product_vector_feature GROUP BY generate_date ORDER BY generate_date desc LIMIT 3
    </select>
</mapper>