ProductPriceHistoryMapper.xml 1.91 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.ProductPriceHistoryMapper">

    <resultMap id="BaseResultMap" type="com.yoho.search.dal.model.ProductPriceHistory">
        <id column="product_skn" property="productSkn" jdbcType="INTEGER" />
        <result column="current_sales_price" property="currentSalesPrice" jdbcType="DECIMAL" />
        <result column="history_sales_price" property="historySalesPrice" jdbcType="DECIMAL" />
        <result column="update_time" property="updateTime" jdbcType="INTEGER" />
    </resultMap>

    <sql id="Base_Column_List">
        product_skn,current_sales_price,history_sales_price,update_time
    </sql>

    <insert id="insert" parameterType="com.yoho.search.dal.model.ProductPriceHistory" timeout="20000">
        insert ignore into product_price_history (product_skn,current_sales_price,history_sales_price,update_time)
        values (
        #{productSkn,jdbcType=INTEGER},#{currentSalesPrice,jdbcType=DECIMAL},#{historySalesPrice,jdbcType=DECIMAL},#{updateTime,jdbcType=INTEGER}
        )
    </insert>

    <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" timeout="20000">
        delete from product_price_history where product_skn = #{productSkn}
    </delete>

    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" timeout="20000">
        select <include refid="Base_Column_List" /> from product_price_history where product_skn = #{productSkn}
    </select>

    <update id="backupHistoryPrice">
        update product_price_history set history_sales_price = current_sales_price
    </update>

    <update id="updateCurrentPrice">
        update product_price_history a INNER JOIN product_price b on a.product_skn = b.product_skn set a.current_sales_price = b.current_price
    </update>

</mapper>