<?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.bonus.material.ma.mapper.TypeLeasePriceHisMapper">
    <resultMap type="com.bonus.material.ma.domain.TypeLeasePriceHis" id="TypeLeasePriceHisResult">
        <result property="ID"    column="ID"    />
        <result property="typeId"    column="type_id"    />
        <result property="leasePrice"    column="lease_price"    />
        <result property="newLeasePrice"    column="new_lease_price"    />
        <result property="priceProp"    column="price_prop"    />
        <result property="startDate"    column="start_date"    />
        <result property="endDate"    column="end_date"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectTypeLeasePriceHisVo">
        select ID, type_id, lease_price, new_lease_price, price_prop, start_date, end_date, del_flag, create_time, update_time from ma_type_lease_price_his
    </sql>

    <select id="selectTypeLeasePriceHisList" parameterType="com.bonus.material.ma.domain.TypeLeasePriceHis" resultMap="TypeLeasePriceHisResult">
        <include refid="selectTypeLeasePriceHisVo"/>
        <where>  
            <if test="leasePrice != null "> and lease_price = #{leasePrice}</if>
            <if test="newLeasePrice != null "> and new_lease_price = #{newLeasePrice}</if>
            <if test="priceProp != null "> and price_prop = #{priceProp}</if>
            <if test="startDate != null "> and start_date = #{startDate}</if>
            <if test="endDate != null "> and end_date = #{endDate}</if>
        </where>
    </select>
    
    <select id="selectTypeLeasePriceHisByID" parameterType="Long" resultMap="TypeLeasePriceHisResult">
        <include refid="selectTypeLeasePriceHisVo"/>
        where ID = #{ID}
    </select>
        
    <insert id="insertTypeLeasePriceHis" parameterType="com.bonus.material.ma.domain.TypeLeasePriceHis" useGeneratedKeys="true" keyProperty="ID">
        insert into ma_type_lease_price_his
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="typeId != null">type_id,</if>
            <if test="leasePrice != null">lease_price,</if>
            <if test="newLeasePrice != null">new_lease_price,</if>
            <if test="priceProp != null">price_prop,</if>
            <if test="startDate != null">start_date,</if>
            <if test="endDate != null">end_date,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="typeId != null">#{typeId},</if>
            <if test="leasePrice != null">#{leasePrice},</if>
            <if test="newLeasePrice != null">#{newLeasePrice},</if>
            <if test="priceProp != null">#{priceProp},</if>
            <if test="startDate != null">#{startDate},</if>
            <if test="endDate != null">#{endDate},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateTypeLeasePriceHis" parameterType="com.bonus.material.ma.domain.TypeLeasePriceHis">
        update ma_type_lease_price_his
        <trim prefix="SET" suffixOverrides=",">
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="leasePrice != null">lease_price = #{leasePrice},</if>
            <if test="newLeasePrice != null">new_lease_price = #{newLeasePrice},</if>
            <if test="priceProp != null">price_prop = #{priceProp},</if>
            <if test="startDate != null">start_date = #{startDate},</if>
            <if test="endDate != null">end_date = #{endDate},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where ID = #{ID}
    </update>

    <delete id="deleteTypeLeasePriceHisByID" parameterType="Long">
        delete from ma_type_lease_price_his where ID = #{ID}
    </delete>

    <delete id="deleteTypeLeasePriceHisByIDs" parameterType="String">
        delete from ma_type_lease_price_his where ID in 
        <foreach item="ID" collection="array" open="(" separator="," close=")">
            #{ID}
        </foreach>
    </delete>
</mapper>