<?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.chinaweal.aiccs.aicepsqy.mapper.datamove.TRGuarantyMapper">

    <!-- 插入担保信息 -->
    <insert id="addTRGuarantyInfo" parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.TRGuarantyModel" useGeneratedKeys="false">
        <![CDATA[
        insert into
            TRGuarantyTemp(GaID,EntityNo,EntID,DebtorName,NameIsShow,GaType,GaTypeIsShow,Rage,RageIsShow,
                       PefPerFrom,PefPerTo,PefPerIsShow,CreditorName,PriClaSecKind,PriClaSecAm,Guaranperiod,IsShowStatus,isShow)
        values
            (
                #{entity.gaId,jdbcType=CHAR},
                #{entity.entityNo,jdbcType=CHAR},
                #{entity.entId,jdbcType=CHAR},
                #{entity.debtorName,jdbcType=VARCHAR},
                #{entity.nameIsShow,jdbcType=CHAR},
                #{entity.gaType,jdbcType=CHAR},
                #{entity.gaTypeIsShow,jdbcType=CHAR},
                #{entity.rage,jdbcType=VARCHAR},
                #{entity.rageIsShow,jdbcType=CHAR},
                #{entity.pefPerFrom,jdbcType=TIMESTAMP},
                #{entity.pefPerTo,jdbcType=TIMESTAMP},
                #{entity.pefPerIsShow,jdbcType=CHAR},
                #{entity.creditorName,jdbcType=VARCHAR},
                #{entity.priClaSecKind,jdbcType=VARCHAR},
                #{entity.priClaSecAm,jdbcType=NUMERIC},
                #{entity.guaranperiod,jdbcType=CHAR},
                #{entity.isShowStatus,jdbcType=CHAR},
                #{entity.isShow,jdbcType=CHAR}
            )
        ]]>
    </insert>

    <insert id="addTRGuarantyInfozs" parameterType="com.chinaweal.aiccs.aicepsqy.entity.datamove.TRGuarantyModel" useGeneratedKeys="false">
        <![CDATA[
        insert into
            TRGuaranty(GaID,EntityNo,EntID,DebtorName,NameIsShow,GaType,GaTypeIsShow,Rage,RageIsShow,
                           PefPerFrom,PefPerTo,PefPerIsShow,CreditorName,PriClaSecKind,PriClaSecAm,Guaranperiod,IsShowStatus,isShow)
        values
            (
                #{entity.gaId,jdbcType=CHAR},
                #{entity.entityNo,jdbcType=CHAR},
                #{entity.entId,jdbcType=CHAR},
                #{entity.debtorName,jdbcType=VARCHAR},
                #{entity.nameIsShow,jdbcType=CHAR},
                #{entity.gaType,jdbcType=CHAR},
                #{entity.gaTypeIsShow,jdbcType=CHAR},
                #{entity.rage,jdbcType=VARCHAR},
                #{entity.rageIsShow,jdbcType=CHAR},
                #{entity.pefPerFrom,jdbcType=TIMESTAMP},
                #{entity.pefPerTo,jdbcType=TIMESTAMP},
                #{entity.pefPerIsShow,jdbcType=CHAR},
                #{entity.creditorName,jdbcType=VARCHAR},
                #{entity.priClaSecKind,jdbcType=VARCHAR},
                #{entity.priClaSecAm,jdbcType=NUMERIC},
                #{entity.guaranperiod,jdbcType=CHAR},
                #{entity.isShowStatus,jdbcType=CHAR},
                #{entity.isShow,jdbcType=CHAR}
            )
        ]]>
    </insert>

    <!-- 根据GaID查询担保信息 -->
    <select id="selectByGaId" resultType="com.chinaweal.aiccs.aicepsqy.entity.datamove.TRGuarantyModel">
        <![CDATA[
        select
            GaID,EntityNo,EntID,DebtorName,NameIsShow,GaType,GaTypeIsShow,Rage,RageIsShow,
            PefPerFrom,PefPerTo,PefPerIsShow,CreditorName,PriClaSecKind,PriClaSecAm,Guaranperiod,IsShowStatus,isShow
        from TRGuaranty
        where GaID = #{gaId,jdbcType=CHAR}
        ]]>
    </select>

    <!-- 根据GaID删除担保信息 -->
    <delete id="deleteByGaId">
        <![CDATA[
        delete from TRGuarantyTemp
        where GaID = #{gaId,jdbcType=CHAR}
        ]]>
    </delete>

    <delete id="deleteByGaIdzs">
        <![CDATA[
        delete from TRGuaranty
        where GaID = #{gaId,jdbcType=CHAR}
        ]]>
    </delete>

    <!-- 根据EntID查询担保信息列表 -->
    <select id="selectListByEntId" resultType="com.chinaweal.aiccs.aicepsqy.entity.datamove.TRGuarantyModel">
        <![CDATA[
        select
            GaID,EntityNo,EntID,DebtorName,NameIsShow,GaType,GaTypeIsShow,Rage,RageIsShow,
            PefPerFrom,PefPerTo,PefPerIsShow,CreditorName,PriClaSecKind,PriClaSecAm,Guaranperiod,IsShowStatus,isShow
        from TRGuaranty
        where EntID = #{entId,jdbcType=CHAR}
        ]]>
    </select>

</mapper>
