<?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.warehouse.mapper.WhDirectApplyInfoMapper">
    <resultMap type="com.bonus.material.warehouse.domain.WhDirectApplyInfo" id="WhDirectApplyInfoResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="backAgreementId"    column="back_agreement_id"    />
        <result property="backMan"    column="back_man"    />
        <result property="backPhone"    column="back_phone"    />
        <result property="backRemark"    column="back_remark"    />
        <result property="leaseAgreementId"    column="lease_agreement_id"    />
        <result property="leaseMan"    column="lease_man"    />
        <result property="leasePhone"    column="lease_phone"    />
        <result property="leaseRemark"    column="lease_remark"    />
        <result property="dirUrl"    column="dir_url"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="auditor"    column="auditor"    />
        <result property="auditTime"    column="audit_time"    />
        <result property="auditRemark"    column="audit_remark"    />
    </resultMap>

    <sql id="selectWhDirectApplyInfoVo">
        select id, code, back_agreement_id, back_man, back_phone, back_remark, lease_agreement_id, lease_man, lease_phone, lease_remark, dir_url, status, create_time, update_time, auditor, audit_time, audit_remark from wh_direct_apply_info
    </sql>

    <select id="selectWhDirectApplyInfoList" parameterType="com.bonus.material.warehouse.domain.WhDirectApplyInfo" resultMap="WhDirectApplyInfoResult">
        <include refid="selectWhDirectApplyInfoVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="backAgreementId != null "> and back_agreement_id = #{backAgreementId}</if>
            <if test="backMan != null  and backMan != ''"> and back_man = #{backMan}</if>
            <if test="backPhone != null  and backPhone != ''"> and back_phone = #{backPhone}</if>
            <if test="backRemark != null  and backRemark != ''"> and back_remark = #{backRemark}</if>
            <if test="leaseAgreementId != null "> and lease_agreement_id = #{leaseAgreementId}</if>
            <if test="leaseMan != null  and leaseMan != ''"> and lease_man = #{leaseMan}</if>
            <if test="leasePhone != null  and leasePhone != ''"> and lease_phone = #{leasePhone}</if>
            <if test="leaseRemark != null  and leaseRemark != ''"> and lease_remark = #{leaseRemark}</if>
            <if test="dirUrl != null  and dirUrl != ''"> and dir_url = #{dirUrl}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="auditor != null  and auditor != ''"> and auditor = #{auditor}</if>
            <if test="auditTime != null "> and audit_time = #{auditTime}</if>
            <if test="auditRemark != null  and auditRemark != ''"> and audit_remark = #{auditRemark}</if>
        </where>
    </select>
    
    <select id="selectWhDirectApplyInfoById" parameterType="Long" resultMap="WhDirectApplyInfoResult">
        <include refid="selectWhDirectApplyInfoVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertWhDirectApplyInfo" parameterType="com.bonus.material.warehouse.domain.WhDirectApplyInfo" useGeneratedKeys="true" keyProperty="id">
        insert into wh_direct_apply_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="backAgreementId != null">back_agreement_id,</if>
            <if test="backMan != null">back_man,</if>
            <if test="backPhone != null">back_phone,</if>
            <if test="backRemark != null">back_remark,</if>
            <if test="leaseAgreementId != null">lease_agreement_id,</if>
            <if test="leaseMan != null">lease_man,</if>
            <if test="leasePhone != null">lease_phone,</if>
            <if test="leaseRemark != null">lease_remark,</if>
            <if test="dirUrl != null">dir_url,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="auditor != null">auditor,</if>
            <if test="auditTime != null">audit_time,</if>
            <if test="auditRemark != null">audit_remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="backAgreementId != null">#{backAgreementId},</if>
            <if test="backMan != null">#{backMan},</if>
            <if test="backPhone != null">#{backPhone},</if>
            <if test="backRemark != null">#{backRemark},</if>
            <if test="leaseAgreementId != null">#{leaseAgreementId},</if>
            <if test="leaseMan != null">#{leaseMan},</if>
            <if test="leasePhone != null">#{leasePhone},</if>
            <if test="leaseRemark != null">#{leaseRemark},</if>
            <if test="dirUrl != null">#{dirUrl},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="auditor != null">#{auditor},</if>
            <if test="auditTime != null">#{auditTime},</if>
            <if test="auditRemark != null">#{auditRemark},</if>
         </trim>
    </insert>

    <update id="updateWhDirectApplyInfo" parameterType="com.bonus.material.warehouse.domain.WhDirectApplyInfo">
        update wh_direct_apply_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="backAgreementId != null">back_agreement_id = #{backAgreementId},</if>
            <if test="backMan != null">back_man = #{backMan},</if>
            <if test="backPhone != null">back_phone = #{backPhone},</if>
            <if test="backRemark != null">back_remark = #{backRemark},</if>
            <if test="leaseAgreementId != null">lease_agreement_id = #{leaseAgreementId},</if>
            <if test="leaseMan != null">lease_man = #{leaseMan},</if>
            <if test="leasePhone != null">lease_phone = #{leasePhone},</if>
            <if test="leaseRemark != null">lease_remark = #{leaseRemark},</if>
            <if test="dirUrl != null">dir_url = #{dirUrl},</if>
            <if test="status != null">status = #{status},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="auditor != null">auditor = #{auditor},</if>
            <if test="auditTime != null">audit_time = #{auditTime},</if>
            <if test="auditRemark != null">audit_remark = #{auditRemark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteWhDirectApplyInfoById" parameterType="Long">
        delete from wh_direct_apply_info where id = #{id}
    </delete>

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