ProductHeatValuesMapper.xml 2.99 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.ProductHeatValuesMapper" >

    <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductHeatValues" >
    <id column="product_skn" property="productSkn" jdbcType="INTEGER" />
    <result column="date_id" property="dateId" jdbcType="VARCHAR" />
    <result column="shareorder_num" property="shareorderNum" jdbcType="DECIMAL" />
    <result column="sale_num" property="saleNum" jdbcType="DECIMAL" />
    <result column="cart_num" property="cartNum" jdbcType="DECIMAL" />
    <result column="favorite_num" property="favoriteNum" jdbcType="DECIMAL" />
    <result column="comments_score" property="commentsScore" jdbcType="DECIMAL" />
    <result column="ctr_value" property="ctrValue" jdbcType="DECIMAL" />
    <result column="sale_amount" property="saleAmount" jdbcType="DECIMAL" />
    <result column="profit_amount" property="profitAmount" jdbcType="DECIMAL" />
    <result column="last_update_time" property="lastUpdateTime" jdbcType="INTEGER" />
    </resultMap>

    <resultMap id="MonitorResultMap" type="com.yoho.search.dal.model.BigdataMonitor">
        <result column="date_id" property="dateId" jdbcType="VARCHAR"/>
        <result column="num" property="num" jdbcType="INTEGER"/>
    </resultMap>

    <sql id="Base_Column_List" >
    product_skn, date_id, shareorder_num, sale_num, cart_num, favorite_num, comments_score, 
    ctr_value, sale_amount, profit_amount, last_update_time
    </sql>

    <select id="selectHeatValuesOfLatestDateBySkn" resultMap="BaseResultMap" timeout="20000">
        <![CDATA[
		select * from product_heat_values p
		where
		date_id = #{dateId}
		and
		p.product_skn in
		]]>
        <foreach item="item" index="index" collection="sknList"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>

    <select id="selectLatestDateId" resultType="java.lang.Integer">
        select max(date_id) from product_heat_values
    </select>

    <select id="selectCount" resultType="java.lang.Integer" timeout="20000">
        SELECT count(*) FROM product_heat_values
        where
        date_id = #{dateId}
    </select>

    <select id="selectSknByDate" resultType="java.lang.Long" timeout="20000">
        SELECT product_skn FROM product_heat_values where date_id = #{dateId,jdbcType=VARCHAR} limit #{pageSize}
    </select>

    <delete id="deleteBatch">
        <![CDATA[
        DELETE FROM product_heat_values
        WHERE
        date_id = #{dateId,jdbcType=VARCHAR}
        AND
        ]]>
        product_skn in
        <foreach item="item" index="index" collection="sknList" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <select id="selectCountGroupByDateId" resultMap="MonitorResultMap">
        SELECT date_id, count(*) num FROM product_heat_values GROUP BY date_id ORDER BY date_id desc LIMIT 3
    </select>

</mapper>