<?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.mtcarpenter.mall.mapper.PmsProductFullReductionMapper">
    <resultMap id="BaseResultMap" type="com.mtcarpenter.mall.model.PmsProductFullReduction">
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="product_id" jdbcType="BIGINT" property="productId"/>
        <result column="full_price" jdbcType="DECIMAL" property="fullPrice"/>
        <result column="reduce_price" jdbcType="DECIMAL" property="reducePrice"/>
    </resultMap>
    <sql id="Example_Where_Clause">
        <where>
            <foreach collection="oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Update_By_Example_Where_Clause">
        <where>
            <foreach collection="example.oredCriteria" item="criteria" separator="or">
                <if test="criteria.valid">
                    <trim prefix="(" prefixOverrides="and" suffix=")">
                        <foreach collection="criteria.criteria" item="criterion">
                            <choose>
                                <when test="criterion.noValue">
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue">
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue">
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue">
                                    and ${criterion.condition}
                                    <foreach close=")" collection="criterion.value" item="listItem" open="("
                                             separator=",">
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <sql id="Base_Column_List">
    id, product_id, full_price, reduce_price
  </sql>
    <select id="selectByExample" parameterType="com.mtcarpenter.mall.model.PmsProductFullReductionExample"
            resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from pms_product_full_reduction
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from pms_product_full_reduction
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from pms_product_full_reduction
    where id = #{id,jdbcType=BIGINT}
  </delete>
    <delete id="deleteByExample" parameterType="com.mtcarpenter.mall.model.PmsProductFullReductionExample">
        delete from pms_product_full_reduction
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.mtcarpenter.mall.model.PmsProductFullReduction">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into pms_product_full_reduction (product_id, full_price, reduce_price
        )
        values (#{productId,jdbcType=BIGINT}, #{fullPrice,jdbcType=DECIMAL}, #{reducePrice,jdbcType=DECIMAL}
        )
    </insert>
    <insert id="insertSelective" parameterType="com.mtcarpenter.mall.model.PmsProductFullReduction">
        <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
            SELECT LAST_INSERT_ID()
        </selectKey>
        insert into pms_product_full_reduction
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="productId != null">
                product_id,
            </if>
            <if test="fullPrice != null">
                full_price,
            </if>
            <if test="reducePrice != null">
                reduce_price,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="productId != null">
                #{productId,jdbcType=BIGINT},
            </if>
            <if test="fullPrice != null">
                #{fullPrice,jdbcType=DECIMAL},
            </if>
            <if test="reducePrice != null">
                #{reducePrice,jdbcType=DECIMAL},
            </if>
        </trim>
    </insert>
    <select id="countByExample" parameterType="com.mtcarpenter.mall.model.PmsProductFullReductionExample"
            resultType="java.lang.Long">
        select count(*) from pms_product_full_reduction
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update pms_product_full_reduction
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=BIGINT},
            </if>
            <if test="record.productId != null">
                product_id = #{record.productId,jdbcType=BIGINT},
            </if>
            <if test="record.fullPrice != null">
                full_price = #{record.fullPrice,jdbcType=DECIMAL},
            </if>
            <if test="record.reducePrice != null">
                reduce_price = #{record.reducePrice,jdbcType=DECIMAL},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update pms_product_full_reduction
        set id = #{record.id,jdbcType=BIGINT},
        product_id = #{record.productId,jdbcType=BIGINT},
        full_price = #{record.fullPrice,jdbcType=DECIMAL},
        reduce_price = #{record.reducePrice,jdbcType=DECIMAL}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective" parameterType="com.mtcarpenter.mall.model.PmsProductFullReduction">
        update pms_product_full_reduction
        <set>
            <if test="productId != null">
                product_id = #{productId,jdbcType=BIGINT},
            </if>
            <if test="fullPrice != null">
                full_price = #{fullPrice,jdbcType=DECIMAL},
            </if>
            <if test="reducePrice != null">
                reduce_price = #{reducePrice,jdbcType=DECIMAL},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.mtcarpenter.mall.model.PmsProductFullReduction">
    update pms_product_full_reduction
    set product_id = #{productId,jdbcType=BIGINT},
      full_price = #{fullPrice,jdbcType=DECIMAL},
      reduce_price = #{reducePrice,jdbcType=DECIMAL}
    where id = #{id,jdbcType=BIGINT}
  </update>
</mapper>