UfoProductPoolDetailMapper.xml 2.28 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.ufo.dal.UfoProductPoolDetailMapper">
    <resultMap id="BaseResultMap" type="com.yoho.ufo.model.goodsmanage.ProductPoolDetails">
       <result column="id" property="id" jdbcType="INTEGER" />
       <result column="pool_id" property="poolId" jdbcType="INTEGER" />
       <result column="product_id" property="productId" jdbcType="INTEGER" />
       <result column="create_time" property="createTime" jdbcType="INTEGER" />
       <result column="order_by" property="orderBy" jdbcType="INTEGER" />
    </resultMap>

    <sql id="Base_Column_List">
        id, pool_id, product_id, create_time, order_by
    </sql>

    <insert id="batchInsertProductPoolDetails" parameterType="list">
        insert into product_pool_detail(pool_id, product_id, create_time, order_by) values
        <foreach collection="list" item="item" separator="," index="index">
            (#{item.poolId}, #{item.productId}, #{item.createTime}, #{item.orderBy})
        </foreach>
    </insert>

    <delete id="deleteProductPoolDetailsByPoolId">
        delete from product_pool_detail where pool_id = #{poolId}
    </delete>

    <delete id="deleteProductPoolDetail">
        DELETE FROM product_pool_detail WHERE pool_id = #{productPoolId} AND product_id = #{productId}
    </delete>
    
    <select id="selectByPoolIdAndProductId" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from product_pool_detail where 1=1
        <if test="poolId != null">  
         and pool_id = #{poolId}
        </if>
        <if test="productId != null">  
         and product_id = #{productId}
        </if>
    </select>
    
    <select id="selectByPoolIdAndOrderBy" resultMap="BaseResultMap">
        select <include refid="Base_Column_List" />
        from product_pool_detail where 1=1
        <if test="poolId != null">  
         and pool_id = #{poolId}
        </if>
        <if test="orderBy != null">  
         and order_by = #{orderBy}
        </if>
    </select>
    
    <update id="updateProductOrderBy">
        update product_pool_detail set order_by=#{orderBy} where pool_id=#{poolId} and product_id=#{productId}
    </update>
    
</mapper>