<?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.ruoyi.system.mapper.TdIndentureMapper">
    
    <resultMap type="TdIndenture" id="TdIndentureResult">
        <result property="indentureId"    column="INDENTURE_ID"    />
        <result property="indentureName"    column="INDENTURE_NAME"    />
        <result property="indentureAddress"    column="INDENTURE_ADDRESS"    />
        <result property="indenturePhone"    column="INDENTURE_PHONE"    />
        <result property="indentureMobile"    column="INDENTURE_MOBILE"    />
        <result property="indentureLinkman"    column="INDENTURE_LINKMAN"    />
        <result property="linkmanPhone"    column="LINKMAN_PHONE"    />
        <result property="linkmanMobile"    column="LINKMAN_MOBILE"    />
        <result property="indentureState"    column="INDENTURE_STATE"    />
        <result property="remark"    column="REMARK"    />
        <result property="createStaffid"    column="CREATE_STAFFID"    />
        <result property="createDate"    column="CREATE_DATE"    />
    </resultMap>

    <sql id="selectTdIndentureVo">
        select INDENTURE_ID, INDENTURE_NAME, INDENTURE_ADDRESS, INDENTURE_PHONE, INDENTURE_MOBILE, INDENTURE_LINKMAN, LINKMAN_PHONE, LINKMAN_MOBILE, INDENTURE_STATE, REMARK, CREATE_STAFFID, CREATE_DATE from td_indenture
    </sql>

    <select id="selectTdIndentureList" parameterType="TdIndenture" resultMap="TdIndentureResult">
        <include refid="selectTdIndentureVo"/>
        <where>  
            <if test="indentureName != null  and indentureName != ''"> and INDENTURE_NAME like concat('%', #{indentureName}, '%')</if>
            <if test="indentureAddress != null  and indentureAddress != ''"> and INDENTURE_ADDRESS = #{indentureAddress}</if>
            <if test="indenturePhone != null  and indenturePhone != ''"> and INDENTURE_PHONE = #{indenturePhone}</if>
            <if test="indentureMobile != null  and indentureMobile != ''"> and INDENTURE_MOBILE = #{indentureMobile}</if>
            <if test="indentureLinkman != null  and indentureLinkman != ''"> and INDENTURE_LINKMAN = #{indentureLinkman}</if>
            <if test="linkmanPhone != null  and linkmanPhone != ''"> and LINKMAN_PHONE = #{linkmanPhone}</if>
            <if test="linkmanMobile != null  and linkmanMobile != ''"> and LINKMAN_MOBILE = #{linkmanMobile}</if>
            <if test="indentureState != null  and indentureState != ''"> and INDENTURE_STATE = #{indentureState}</if>
            <if test="remark != null  and REMARK != ''"> and REMARK = #{remark}</if>
            <if test="createStaffid != null  and createStaffid != ''"> and CREATE_STAFFID = #{createStaffid}</if>
            <if test="createDate != null "> and CREATE_DATE = #{createDate}</if>
        </where>
    </select>
    
    <select id="selectTdIndentureByIndentureId" parameterType="String" resultMap="TdIndentureResult">
        <include refid="selectTdIndentureVo"/>
        where INDENTURE_ID = #{indentureId}
    </select>
        
    <insert id="insertTdIndenture" parameterType="TdIndenture">
        insert into td_indenture
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="indentureId != null">INDENTURE_ID,</if>
            <if test="indentureName != null">INDENTURE_NAME,</if>
            <if test="indentureAddress != null">INDENTURE_ADDRESS,</if>
            <if test="indenturePhone != null">INDENTURE_PHONE,</if>
            <if test="indentureMobile != null">INDENTURE_MOBILE,</if>
            <if test="indentureLinkman != null">INDENTURE_LINKMAN,</if>
            <if test="linkmanPhone != null">LINKMAN_PHONE,</if>
            <if test="linkmanMobile != null">LINKMAN_MOBILE,</if>
            <if test="indentureState != null">INDENTURE_STATE,</if>
            <if test="remark != null">REMARK,</if>
            <if test="createStaffid != null">CREATE_STAFFID,</if>
            <if test="createDate != null">CREATE_DATE,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="indentureId != null">#{indentureId},</if>
            <if test="indentureName != null">#{indentureName},</if>
            <if test="indentureAddress != null">#{indentureAddress},</if>
            <if test="indenturePhone != null">#{indenturePhone},</if>
            <if test="indentureMobile != null">#{indentureMobile},</if>
            <if test="indentureLinkman != null">#{indentureLinkman},</if>
            <if test="linkmanPhone != null">#{linkmanPhone},</if>
            <if test="linkmanMobile != null">#{linkmanMobile},</if>
            <if test="indentureState != null">#{indentureState},</if>
            <if test="remark != null">#{REMARK},</if>
            <if test="createStaffid != null">#{createStaffid},</if>
            <if test="createDate != null">#{createDate},</if>
         </trim>
    </insert>

    <update id="updateTdIndenture" parameterType="TdIndenture">
        update td_indenture
        <trim prefix="SET" suffixOverrides=",">
            <if test="indentureName != null">INDENTURE_NAME = #{indentureName},</if>
            <if test="indentureAddress != null">INDENTURE_ADDRESS = #{indentureAddress},</if>
            <if test="indenturePhone != null">INDENTURE_PHONE = #{indenturePhone},</if>
            <if test="indentureMobile != null">INDENTURE_MOBILE = #{indentureMobile},</if>
            <if test="indentureLinkman != null">INDENTURE_LINKMAN = #{indentureLinkman},</if>
            <if test="linkmanPhone != null">LINKMAN_PHONE = #{linkmanPhone},</if>
            <if test="linkmanMobile != null">LINKMAN_MOBILE = #{linkmanMobile},</if>
            <if test="indentureState != null">INDENTURE_STATE = #{indentureState},</if>
            <if test="remark != null">REMARK = #{remark},</if>
            <if test="createStaffid != null">CREATE_STAFFID = #{createStaffid},</if>
            <if test="createDate != null">CREATE_DATE = #{createDate},</if>
        </trim>
        where INDENTURE_ID = #{indentureId}
    </update>

    <delete id="deleteTdIndentureByIndentureId" parameterType="String">
        delete from td_indenture where INDENTURE_ID = #{indentureId}
    </delete>

    <delete id="deleteTdIndentureByIndentureIds" parameterType="String">
        delete from td_indenture where INDENTURE_ID in 
        <foreach item="indentureId" collection="array" open="(" separator="," close=")">
            #{indentureId}
        </foreach>
    </delete>

</mapper>