<?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.iamberry.wechat.service.mapper.IntegralProductGradeMapper">
    <resultMap  id="BaseResultMap" type="IntegralProductGrade" >
        <result    column="product_grade_id"    property="productGradeId" />
        <result    column="integral_product_id"    property="integralProductId" />
        <result    column="rank_id"    property="rankId" />
        <result    column="product_grade_time"    property="productGradeTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.product_grade_id,
        t.integral_product_id,
        t.rank_id,
        t.product_grade_time
    </sql>
    <select id="getIntegralProductGradeList" resultMap="BaseResultMap" parameterType="IntegralProductGrade" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_product_grade t
        <where>
            <if test="productGradeId != null ">
                AND t.product_grade_id = #{productGradeId}
            </if >
            <if test="integralProductId != null ">
                AND t.integral_product_id = #{integralProductId}
            </if >
            <if test="rankId != null ">
                AND t.rank_id = #{rankId}
            </if >
        </where>
    </select>
    <select id="getIntegralProductGradeById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_integral_product_grade t
        where t.product_grade_id= #{productGradeId}
    </select>
    <insert id="save" parameterType="IntegralProductGrade" >
        insert into
        tb_iamberry_integral_product_grade
        (
        product_grade_id,
        integral_product_id,
        rank_id
        )
        values
        (
        #{productGradeId},
        #{integralProductId},
        #{rankId}
        )
    </insert>
    <update id="update" parameterType="IntegralProductGrade" >
        update
        tb_iamberry_integral_product_grade
        <set >
            <if test="productGradeId != null ">
                product_grade_id = #{productGradeId},
            </if >
            <if test="integralProductId != null ">
                integral_product_id = #{integralProductId},
            </if >
            <if test="rankId != null ">
                rank_id = #{rankId},
            </if >
        </set >
        where product_grade_id= #{productGradeId}
    </update>
    <delete id="delete" parameterType="Integer" >
        delete
        tb_iamberry_integral_product_grade
        where product_grade_id=#{productGradeId}
    </delete>
</mapper>
