<?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.goldenwater.slaj.ttsa.mapper.BisTtsaCeriExtApllMapper">

    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCeriExtApll" id="BisTtsaCeriExtApllResult">
        <id property="guid" column="guid"/>
        <result property="ttsaCertGuid" column="ttsa_cert_guid"/>
        <result property="applOrgGuid" column="appl_org_guid"/>
        <result property="certCode" column="cert_code"/>
        <result property="holdPers" column="hold_pers"/>
        <result property="issuTime" column="issu_time"/>
        <result property="extSitu" column="ext_situ"/>
        <result property="apllTime" column="apll_time"/>
        <result property="veriTime" column="veri_time"/>
        <result property="veriPers" column="veri_pers"/>
        <result property="veriIfAgree" column="veri_if_agree"/>
        <result property="wiunOpin" column="wiun_opin"/>
        <result property="apprTime" column="appr_time"/>
        <result property="apprPers" column="appr_pers"/>
        <result property="apprIfAgree" column="appr_if_agree"/>
        <result property="apprWiunOpin" column="appr_wiun_opin"/>
        <result property="report" column="report"/>
        <result property="ifAgreeRep" column="if_agree_rep"/>
        <result property="note" column="note"/>
        <result property="collTime" column="coll_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="recPers" column="rec_pers"/>
        <result property="punoGuid" column="puno_guid"/>
        <result property="flowStat" column="flow_stat"/>
    </resultMap>

    <sql id="selectBisTtsaCeriExtApllVo">
        select guid, ttsa_cert_guid, appl_org_guid, cert_code, hold_pers, issu_time, ext_situ, apll_time, veri_time, veri_pers, veri_if_agree, wiun_opin, appr_time, appr_pers, appr_if_agree, appr_wiun_opin, report, if_agree_rep, note, coll_time, upd_time, rec_pers, puno_guid, flow_stat
        from bis_ttsa_ceri_ext_apll
    </sql>

    <select id="selectBisTtsaCeriExtApllAll" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCeriExtApll" resultMap="BisTtsaCeriExtApllResult">
        <include refid="selectBisTtsaCeriExtApllVo"/>
        order by coll_time desc
    </select>

    <select id="selectBisTtsaCeriExtApllList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCeriExtApll" resultMap="BisTtsaCeriExtApllResult">
        <include refid="selectBisTtsaCeriExtApllVo"/>
        <where>
            <if test="ttsaCertGuid != null and ttsaCertGuid != ''">and ttsa_cert_guid = #{ttsaCertGuid}</if>
            <if test="certCode != null and certCode != ''">and cert_code = #{certCode}</if>
            <if test="veriIfAgree != null and veriIfAgree != ''">and veri_if_agree = #{veriIfAgree}</if>
        </where>
        order by coll_time desc
    </select>

    <select id="selectBisTtsaCeriExtApllByGuid" parameterType="String" resultMap="BisTtsaCeriExtApllResult">
        <include refid="selectBisTtsaCeriExtApllVo"/>
        where guid = #{guid}
    </select>

    <insert id="insertBisTtsaCeriExtApll" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCeriExtApll" useGeneratedKeys="true" keyProperty="guid">
        insert into bis_ttsa_ceri_ext_apll (
            guid, ttsa_cert_guid, appl_org_guid, cert_code, hold_pers, issu_time, ext_situ, apll_time, veri_time, veri_pers, veri_if_agree, wiun_opin, appr_time, appr_pers, appr_if_agree, appr_wiun_opin, report, if_agree_rep, note, coll_time, upd_time, rec_pers, puno_guid, flow_stat
        ) values (
            #{guid}, #{ttsaCertGuid}, #{applOrgGuid}, #{certCode}, #{holdPers}, #{issuTime}, #{extSitu}, #{apllTime}, #{veriTime}, #{veriPers}, #{veriIfAgree}, #{wiunOpin}, #{apprTime}, #{apprPers}, #{apprIfAgree}, #{apprWiunOpin}, #{report}, #{ifAgreeRep}, #{note}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, #{recPers}, #{punoGuid}, #{flowStat}
        )
    </insert>

    <update id="updateBisTtsaCeriExtApll" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCeriExtApll">
        update bis_ttsa_ceri_ext_apll
        <set>
            <if test="ttsaCertGuid != null">ttsa_cert_guid = #{ttsaCertGuid},</if>
            <if test="applOrgGuid != null">appl_org_guid = #{applOrgGuid},</if>
            <if test="certCode != null">cert_code = #{certCode},</if>
            <if test="holdPers != null">hold_pers = #{holdPers},</if>
            <if test="issuTime != null">issu_time = #{issuTime},</if>
            <if test="extSitu != null">ext_situ = #{extSitu},</if>
            <if test="apllTime != null">apll_time = #{apllTime},</if>
            <if test="veriTime != null">veri_time = #{veriTime},</if>
            <if test="veriPers != null">veri_pers = #{veriPers},</if>
            <if test="veriIfAgree != null">veri_if_agree = #{veriIfAgree},</if>
            <if test="wiunOpin != null">wiun_opin = #{wiunOpin},</if>
            <if test="apprTime != null">appr_time = #{apprTime},</if>
            <if test="apprPers != null">appr_pers = #{apprPers},</if>
            <if test="apprIfAgree != null">appr_if_agree = #{apprIfAgree},</if>
            <if test="apprWiunOpin != null">appr_wiun_opin = #{apprWiunOpin},</if>
            <if test="report != null">report = #{report},</if>
            <if test="ifAgreeRep != null">if_agree_rep = #{ifAgreeRep},</if>
            <if test="note != null">note = #{note},</if>
            <if test="punoGuid != null">puno_guid = #{punoGuid},</if>
            <if test="flowStat != null">flow_stat = #{flowStat},</if>
            upd_time = CURRENT_TIMESTAMP
        </set>
        where guid = #{guid}
    </update>

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

</mapper>
