<?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.yiqi.recharge.mapper.RechargeCardVersionMapper">

    <resultMap type="RechargeCardVersion" id="RechargeCardVersionResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="code" column="code"/>
        <result property="rechargeAmount" column="recharge_amount"/>
        <result property="giveAmount" column="give_amount"/>
        <result property="givePointAmount" column="give_point_amount"/>
        <result property="status" column="status"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createById" column="create_by_id"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateById" column="update_by_id"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectRechargeCardVersionVo">
        select id, title, code, recharge_amount, give_amount, give_point_amount, status, del_flag, create_by_id, create_by, create_time, update_by_id, update_by, update_time, remark
        from recharge_card_version
    </sql>

    <select id="selectRechargeCardVersionList" parameterType="RechargeCardVersion" resultMap="RechargeCardVersionResult">
        <include refid="selectRechargeCardVersionVo"/>
        <where>
            del_flag='0'
            <if test="title != null  and title != ''">
                and title like concat('%', #{title}, '%')
            </if>
            <if test="code != null  and code != ''">
                and code like concat('%', #{code}, '%')
            </if>
        </where>
        order by create_time desc
    </select>

    <select id="selectRechargeCardVersionById" parameterType="Long"
            resultMap="RechargeCardVersionResult">
        <include refid="selectRechargeCardVersionVo"/>
        where id = #{id}
    </select>

    <insert id="insertRechargeCardVersion" parameterType="RechargeCardVersion">
        insert into recharge_card_version
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,
            </if>
            <if test="title != null">title,
            </if>
            <if test="code != null">code,
            </if>
            <if test="rechargeAmount != null">recharge_amount,
            </if>
            <if test="giveAmount != null">give_amount,
            </if>
            <if test="givePointAmount != null">give_point_amount,
            </if>
            <if test="status != null">status,
            </if>
            <if test="delFlag != null">del_flag,
            </if>
            <if test="createById != null">create_by_id,
            </if>
            <if test="createBy != null">create_by,
            </if>
            <if test="createTime != null">create_time,
            </if>
            <if test="updateById != null">update_by_id,
            </if>
            <if test="updateBy != null">update_by,
            </if>
            <if test="updateTime != null">update_time,
            </if>
            <if test="remark != null">remark,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},
            </if>
            <if test="title != null">#{title},
            </if>
            <if test="code != null">#{code},
            </if>
            <if test="rechargeAmount != null">#{rechargeAmount},
            </if>
            <if test="giveAmount != null">#{giveAmount},
            </if>
            <if test="givePointAmount != null">#{givePointAmount},
            </if>
            <if test="status != null">#{status},
            </if>
            <if test="delFlag != null">#{delFlag},
            </if>
            <if test="createById != null">#{createById},
            </if>
            <if test="createBy != null">#{createBy},
            </if>
            <if test="createTime != null">#{createTime},
            </if>
            <if test="updateById != null">#{updateById},
            </if>
            <if test="updateBy != null">#{updateBy},
            </if>
            <if test="updateTime != null">#{updateTime},
            </if>
            <if test="remark != null">#{remark},
            </if>
        </trim>
    </insert>

    <update id="updateRechargeCardVersion" parameterType="RechargeCardVersion">
        update recharge_card_version
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title =
                #{title},
            </if>
            <if test="code != null">code =
                #{code},
            </if>
            <if test="rechargeAmount != null">recharge_amount =
                #{rechargeAmount},
            </if>
            <if test="giveAmount != null">give_amount =
                #{giveAmount},
            </if>
            <if test="givePointAmount != null">give_point_amount =
                #{givePointAmount},
            </if>
            <if test="status != null">status =
                #{status},
            </if>
            <if test="delFlag != null">del_flag =
                #{delFlag},
            </if>
            <if test="createById != null">create_by_id =
                #{createById},
            </if>
            <if test="createBy != null">create_by =
                #{createBy},
            </if>
            <if test="createTime != null">create_time =
                #{createTime},
            </if>
            <if test="updateById != null">update_by_id =
                #{updateById},
            </if>
            <if test="updateBy != null">update_by =
                #{updateBy},
            </if>
            <if test="updateTime != null">update_time =
                #{updateTime},
            </if>
            <if test="remark != null">remark =
                #{remark},
            </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRechargeCardVersionById" parameterType="Long">
        update recharge_card_version set del_flag='2' where id = #{id}
    </delete>

    <delete id="deleteRechargeCardVersionByIds" parameterType="String">
        update recharge_card_version set del_flag='2' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>



</mapper>