<?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.SettlementGiftMapper">
    <resultMap  id="BaseResultMap" type="SettlementGift" >
        <result    column="sett_gift_id"    property="settGiftId" />
        <result    column="sett_gift_fill_color_id"    property="settGiftFillColorId" />
        <result    column="sett_gift_gift_color_id"    property="settGiftGiftColorId" />
        <result    column="sett_gift_price"    property="settGiftPrice" />
        <result    column="sett_gift_num"    property="settGiftNum" />
        <result    column="sett_gift_status"    property="settGiftStatus" />
        <result    column="sett_gift_create_time"    property="settGiftCreateTime" />
    </resultMap>
    <sql    id="Base_List" >
        t.sett_gift_id,
        t.sett_gift_fill_color_id,
        t.sett_gift_gift_color_id,
        t.sett_gift_price,
        t.sett_gift_num,
        t.sett_gift_status,
        t.sett_gift_create_time
    </sql>
    <select id="getSettlementGiftList" resultMap="BaseResultMap" parameterType="SettlementGift" >
        select
        <include refid="Base_List" />
        from tb_iamberry_settlement_gift t
        <where>
            <if test="settGiftId != null ">
                AND t.sett_gift_id = #{settGiftId}
            </if >
            <if test="settGiftFillColorId != null ">
                AND t.sett_gift_fill_color_id = #{settGiftFillColorId}
            </if >
            <if test="settGiftGiftColorId != null ">
                AND t.sett_gift_gift_color_id = #{settGiftGiftColorId}
            </if >
            <if test="settGiftPrice != null ">
                AND t.sett_gift_price = #{settGiftPrice}
            </if >
            <if test="settGiftNum != null ">
                AND t.sett_gift_num = #{settGiftNum}
            </if >
            <if test="settGiftStatus != null ">
                AND t.sett_gift_status = #{settGiftStatus}
            </if >
        </where>
    </select>
    <select id="getSettlementGiftById" resultMap="BaseResultMap" parameterType="Integer" >
        select
        <include refid="Base_List" />
        from tb_iamberry_settlement_gift t
        where t.sett_gift_id= #{settGiftId}
    </select>
    <insert id="save" parameterType="SettlementGift" >
        insert into
        tb_iamberry_settlement_gift
        (
        sett_gift_id,
        sett_gift_fill_color_id,
        sett_gift_gift_color_id,
        sett_gift_price,
        sett_gift_num,
        sett_gift_status
        )
        values
        (
        #{settGiftId},
        #{settGiftFillColorId},
        #{settGiftGiftColorId},
        #{settGiftPrice},
        #{settGiftNum},
        #{settGiftStatus}
        )
    </insert>
    <update id="update" parameterType="SettlementGift" >
        update
        tb_iamberry_settlement_gift
        <set >
            <if test="settGiftFillColorId != null ">
                sett_gift_fill_color_id = #{settGiftFillColorId},
            </if >
            <if test="settGiftGiftColorId != null ">
                sett_gift_gift_color_id = #{settGiftGiftColorId},
            </if >
            <if test="settGiftPrice != null ">
                sett_gift_price = #{settGiftPrice},
            </if >
            <if test="settGiftNum != null ">
                sett_gift_num = #{settGiftNum},
            </if >
            <if test="settGiftStatus != null ">
                sett_gift_status = #{settGiftStatus},
            </if >
        </set >
        where sett_gift_id= #{settGiftId}
    </update>
</mapper>