SknCtrValueMapper.xml 4.08 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.SknCtrValueMapper" >
  <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.SknCtrValue" >
    <id column="product_skn" property="productSkn" jdbcType="INTEGER" />
    <result column="date_id" property="dateId" jdbcType="VARCHAR" />
    <result column="ctr_value" property="ctrValue" jdbcType="BigDecimal" />
    <result column="create_time" property="createTime" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    product_skn, date_id, ctr_value, create_time
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from skn_ctr_value
    where product_skn = #{productSkn,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from skn_ctr_value
    where product_skn = #{productSkn,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.yoho.search.dal.model.SknCtrValue" >
    insert into skn_ctr_value (product_skn, date_id, ctr_value, 
      create_time)
    values (#{productSkn,jdbcType=INTEGER}, #{dateId,jdbcType=VARCHAR}, #{ctrValue,jdbcType=BigDecimal},
      #{createTime,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.yoho.search.dal.model.SknCtrValue" >
    insert into skn_ctr_value
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="productSkn != null" >
        product_skn,
      </if>
      <if test="dateId != null" >
        date_id,
      </if>
      <if test="ctrValue != null" >
        ctr_value,
      </if>
      <if test="createTime != null" >
        create_time,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="productSkn != null" >
        #{productSkn,jdbcType=INTEGER},
      </if>
      <if test="dateId != null" >
        #{dateId,jdbcType=VARCHAR},
      </if>
      <if test="ctrValue != null" >
        #{ctrValue,jdbcType=BigDecimal},
      </if>
      <if test="createTime != null" >
        #{createTime,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yoho.search.dal.model.SknCtrValue" >
    update skn_ctr_value
    <set >
      <if test="dateId != null" >
        date_id = #{dateId,jdbcType=VARCHAR},
      </if>
      <if test="ctrValue != null" >
        ctr_value = #{ctrValue,jdbcType=BigDecimal},
      </if>
      <if test="createTime != null" >
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
    </set>
    where product_skn = #{productSkn,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yoho.search.dal.model.SknCtrValue" >
    update skn_ctr_value
    set date_id = #{dateId,jdbcType=VARCHAR},
      ctr_value = #{ctrValue,jdbcType=BigDecimal},
      create_time = #{createTime,jdbcType=INTEGER}
    where product_skn = #{productSkn,jdbcType=INTEGER}
  </update>
    <select id="selectLatestDateId" resultType="java.lang.Integer">
        select max(date_id) from skn_ctr_value
    </select>
    <select id="selectLatestDateBySkn" resultMap="BaseResultMap" timeout="20000">
        <![CDATA[
		select * from skn_ctr_value s
		where
		date_id = #{dateId}
		and
		s.product_skn in
		]]>
        <foreach item="item" index="index" collection="sknList"
                 open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
    <select id="selectSknByDate" resultType="java.lang.Long" timeout="20000">
        SELECT product_skn FROM skn_ctr_value where date_id = #{dateId,jdbcType=VARCHAR} limit #{pageSize}
    </select>
    <delete id="deleteBatch">
        <![CDATA[
        DELETE FROM skn_ctr_value
        WHERE
        date_id = #{dateId,jdbcType=VARCHAR}
        AND
        ]]>
        product_skn in
        <foreach item="item" index="index" collection="sknList" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
</mapper>