<?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.zlpt.equip.mapper.LeaseInfoMapper">
    
    <resultMap type="com.bonus.zlpt.equip.api.domain.LeaseInfo" id="LeaseInfoResult">
        <result property="id"    column="id"    />
        <result property="czNum"    column="cz_num"    />
        <result property="qzNum"    column="qz_num"    />
    </resultMap>

    <sql id="selectLeaseInfoVo">
        select id, cz_num, qz_num from ma_lease_info
    </sql>

    <select id="selectLeaseInfoList" parameterType="com.bonus.zlpt.equip.api.domain.LeaseInfo" resultMap="LeaseInfoResult">
        <include refid="selectLeaseInfoVo"/>
        <where>  
            <if test="czNum != null "> and cz_num = #{czNum}</if>
            <if test="qzNum != null "> and qz_num = #{qzNum}</if>
        </where>
    </select>
    
    <select id="selectLeaseInfoById" parameterType="Long" resultMap="LeaseInfoResult">
        <include refid="selectLeaseInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertLeaseInfo" parameterType="com.bonus.zlpt.equip.api.domain.LeaseInfo">
        insert into ma_lease_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="czNum != null">cz_num,</if>
            <if test="qzNum != null">qz_num,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="czNum != null">#{czNum},</if>
            <if test="qzNum != null">#{qzNum},</if>
         </trim>
    </insert>

    <update id="updateLeaseInfo" parameterType="com.bonus.zlpt.equip.api.domain.LeaseInfo">
        update ma_lease_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="czNum != null">cz_num = #{czNum},</if>
            <if test="qzNum != null">qz_num = #{qzNum},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteLeaseInfoById" parameterType="Long">
        delete from ma_lease_info where id = #{id}
    </delete>

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