<?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.brilliance.isc.mda.dao.EbcMapper">

    <resultMap id="BaseResultMap" type="com.brilliance.isc.bo.Ebc">
<!--            <id property="id" column="ID" jdbcType="BIGINT"/>-->
            <result property="inr" column="inr" jdbcType="CHAR"/>
            <result property="ver" column="VER" jdbcType="VARCHAR"/>
            <result property="actiontype" column="ACTIONTYPE" jdbcType="CHAR"/>
            <result property="actiondesc" column="ACTIONDESC" jdbcType="VARCHAR"/>
            <result property="exguarancode" column="EXGUARANCODE" jdbcType="VARCHAR"/>
            <result property="complianceno" column="COMPLIANCENO" jdbcType="VARCHAR"/>
            <result property="guarantorcode" column="GUARANTORCODE" jdbcType="VARCHAR"/>
            <result property="buscode" column="BUSCODE" jdbcType="VARCHAR"/>
            <result property="bencode" column="BENCODE" jdbcType="VARCHAR"/>
            <result property="bename" column="BENAME" jdbcType="VARCHAR"/>
            <result property="benamen" column="BENAMEN" jdbcType="VARCHAR"/>
            <result property="guperdate" column="GUPERDATE" jdbcType="DATE"/>
            <result property="gupercurr" column="GUPERCURR" jdbcType="CHAR"/>
            <result property="guperamount" column="GUPERAMOUNT" jdbcType="DECIMAL"/>
            <result property="pguperamount" column="PGUPERAMOUNT" jdbcType="DECIMAL"/>
            <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
            <result property="sta" column="STA" jdbcType="CHAR"/>
            <result property="eblinr" column="eblinr" jdbcType="CHAR"/>
            <result property="objtyp" column="OBJTYP" jdbcType="VARCHAR"/>
            <result property="objinr" column="objinr" jdbcType="CHAR"/>
            <result property="credat" column="CREDAT" jdbcType="DATE"/>
    </resultMap>

    <sql id="Base_Column_List">
        inr,VER,
        ACTIONTYPE,ACTIONDESC,EXGUARANCODE,
        COMPLIANCENO,GUARANTORCODE,BUSCODE,
        BENCODE,BENAME,BENAMEN,
        GUPERDATE,GUPERCURR,GUPERAMOUNT,
        PGUPERAMOUNT,REMARK,STA,
        eblinr,OBJTYP,objinr,
        CREDAT
    </sql>

    <select id="selectByInr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ebc
        where inr = #{inr,jdbcType=VARCHAR}
    </select>

    <select id="selectByObjinr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ebc
        where objinr = #{objinr,jdbcType=VARCHAR}
    </select>
    <select id="selectByEblInr" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ebc
        where eblinr = #{eblinr,jdbcType=CHAR}
    </select>

    <insert id="insert">
        insert into ebc (<include refid="Base_Column_List" />)
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            #{inr,jdbcType=CHAR},
            #{ver,jdbcType=VARCHAR},
            #{actiontype,jdbcType=CHAR},
            #{actiondesc,jdbcType=VARCHAR},
            #{exguarancode,jdbcType=VARCHAR},
            #{complianceno,jdbcType=VARCHAR},
            #{guarantorcode,jdbcType=CHAR},
            #{buscode,jdbcType=VARCHAR},
            #{bencode,jdbcType=VARCHAR},
            #{bename,jdbcType=VARCHAR},
            #{benamen,jdbcType=VARCHAR},
            #{guperdate,jdbcType=DATE},
            #{gupercurr,jdbcType=CHAR},
            #{guperamount,jdbcType=DECIMAL},
            #{pguperamount,jdbcType=DECIMAL},
            #{remark,jdbcType=VARCHAR},
            #{sta,jdbcType=CHAR},
            #{eblinr,jdbcType=CHAR},
            #{objtyp,jdbcType=VARCHAR},
            #{objinr,jdbcType=CHAR},
            #{credat,jdbcType=DATE}
        </trim>
    </insert>

    <update id="updateByExguarancode">
        update ebc set sta = 'D'
        where exguarancode = #{exguarancode,jdbcType=VARCHAR}
    </update>

    <update id="updateByPrimaryKeySelective">
        update ebc
        <set>
            <if test="ver != null">ver = #{ver,jdbcType=VARCHAR},</if>
            <if test="actiontype != null">actiontype = #{actiontype,jdbcType=VARCHAR},</if>
            <if test="actiondesc != null">actiondesc = #{actiondesc,jdbcType=VARCHAR},</if>
            <if test="exguarancode != null">exguarancode = #{exguarancode,jdbcType=VARCHAR},</if>
            <if test="complianceno != null">complianceno = #{complianceno,jdbcType=VARCHAR},</if>
            <if test="guarantorcode != null">guarantorcode = #{guarantorcode,jdbcType=VARCHAR},</if>
            <if test="buscode != null">buscode = #{buscode,jdbcType=VARCHAR},</if>
            <if test="bencode != null">bencode = #{bencode,jdbcType=VARCHAR},</if>
            <if test="bename != null">bename = #{bename,jdbcType=VARCHAR},</if>
            <if test="benamen != null">benamen = #{benamen,jdbcType=VARCHAR},</if>
            <if test="guperdate != null">guperdate = #{guperdate,jdbcType=DATE},</if>
            <if test="gupercurr != null">gupercurr = #{gupercurr,jdbcType=VARCHAR},</if>
            <if test="guperamount != null">guperamount = #{guperamount,jdbcType=DECIMAL},</if>
            <if test="pguperamount != null">pguperamount = #{pguperamount,jdbcType=DECIMAL},</if>
            <if test="remark != null">remark = #{remark,jdbcType=VARCHAR},</if>
            <if test="sta != null">sta = #{sta,jdbcType=VARCHAR},</if>
            <if test="eblinr != null">eblinr = #{eblinr,jdbcType=VARCHAR},</if>
            <if test="objtyp != null">objtyp = #{objtyp,jdbcType=VARCHAR},</if>
            <if test="objinr != null">objinr = #{objinr,jdbcType=VARCHAR},</if>
            <if test="credat != null">credat = #{credat,jdbcType=DATE},</if>
        </set>
        where inr = #{inr,jdbcType=VARCHAR}
    </update>
    <delete id="deleteByPrimaryKey">
        delete from ebc
        where inr = #{inr,jdbcType=VARCHAR}
    </delete>

</mapper>