ProductProfitMapper.xml 4.42 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.product.dal.ProductProfitMapper">

    <resultMap id="BaseResultMap" type="com.yoho.product.model.ProductProfit">
        <id column="id" jdbcType="INTEGER" property="id" />
        <result column="product_id" jdbcType="INTEGER" property="productId" />
        <result column="profit_rate" jdbcType="DECIMAL" property="profitRate" />
        <result column="update_time" jdbcType="INTEGER" property="updateTime" />
        <result column="create_time" jdbcType="INTEGER" property="createTime" />
        <result column="del_status" jdbcType="INTEGER" property="delStatus" />
        <result column="edit_user_name" jdbcType="VARCHAR" property="editUserName" />
        <result column="add_user_name" jdbcType="VARCHAR" property="addUserName" />
        <result column="profit_max_price" jdbcType="DECIMAL" property="profitMaxPrice" />
        <result column="profit_min_price" jdbcType="DECIMAL" property="profitMinPrice" />
    </resultMap>

    <select id="selectCount" resultType="java.lang.Integer" parameterType="java.lang.Integer">
        select count(1) from product_profit
        where del_status = 0
        <if test="productId != null &amp;&amp; productId > 0">
            and product_id = #{productId, jdbcType=INTEGER}
        </if>
    </select>

    <select id="selectById" resultMap="BaseResultMap" parameterType="java.lang.Integer">
        select id, product_id, profit_rate, profit_max_price, profit_min_price
        from product_profit
        where id = #{id, jdbcType=INTEGER}
    </select>

    <select id="selectByCondition" resultMap="BaseResultMap">
        select id, product_id, profit_rate, profit_max_price, profit_min_price, create_time, update_time, add_user_name, edit_user_name
        from product_profit
        where del_status = 0
        <if test="productId != null &amp;&amp; productId > 0">
            and product_id = #{productId, jdbcType=INTEGER}
        </if>
        limit #{startIndex}, #{rows}
    </select>


    <update id="updateDelStatus" parameterType="java.lang.Integer">
        update product_profit
        set del_status = 1
        where id = #{id, jdbcType=INTEGER}
    </update>

    <select id="selectByProductIds" resultMap="BaseResultMap">
        select product_id, add_user_name, create_time from product_profit
        where del_status = 0
        and product_id in
        <foreach collection="list" item="productId" separator="," open="(" close=")">
            #{productId, jdbcType=INTEGER}
        </foreach>

    </select>

    <insert id="insertBatchProductProfit">
        replace into product_profit
        (product_id, profit_rate, update_time, create_time, add_user_name, edit_user_name, profit_max_price, profit_min_price)
        values
        <foreach collection="list" item="item" separator=",">
            (#{item.productId, jdbcType=INTEGER},#{item.profitRate, jdbcType=DECIMAL},
             #{item.updateTime, jdbcType=INTEGER},#{item.createTime, jdbcType=INTEGER},
             #{item.addUserName, jdbcType=INTEGER},#{item.editUserName, jdbcType=INTEGER},
             #{item.profitMaxPrice, jdbcType=DECIMAL},#{item.profitMinPrice, jdbcType=DECIMAL}
             )
        </foreach>
    </insert>

    <update id="update">
        update product_profit
        set product_id = #{productId, jdbcType=INTEGER},
            profit_rate = #{profitRate, jdbcType=DECIMAL},
            profit_max_price = #{profitMaxPrice, jdbcType=DECIMAL},
            profit_min_price = #{profitMinPrice, jdbcType=DECIMAL},
            edit_user_name = #{editUserName, jdbcType=VARCHAR},
            update_time = #{updateTime, jdbcType=INTEGER}
        where id = #{id, jdbcType=INTEGER}
    </update>

    <select id="selectByProductId" resultType="java.lang.Integer" resultMap="BaseResultMap">
        select id from product_profit
        where del_status = 0 and product_id = #{productId, jdbcType=INTEGER}
        limit 1
    </select>

    <insert id="insert">
        replace into product_profit
        (product_id, profit_rate, profit_max_price, profit_min_price, add_user_name, create_time)
        values
        (#{productId, jdbcType=INTEGER}, #{profitRate, jdbcType=DECIMAL},
         #{profitMaxPrice, jdbcType=DECIMAL}, #{profitMinPrice, jdbcType=DECIMAL},
         #{addUserName, jdbcType=VARCHAR}, #{createTime, jdbcType=INTEGER})
    </insert>



</mapper>