<?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.BisTtsaCertReisApplMapper">

    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCertReisAppl" id="BisTtsaCertReisApplResult">
        <id property="guid" column="guid"/>
        <result property="applWiunCode" column="appl_wiun_code"/>
        <result property="certCode" column="cert_code"/>
        <result property="issueTime" column="issue_time"/>
        <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="note" column="note"/>
        <result property="collTime" column="coll_time"/>
        <result property="updTime" column="upd_time"/>
        <result property="recPers" column="rec_pers"/>
    </resultMap>

    <sql id="selectBisTtsaCertReisApplVo">
        select guid, appl_wiun_code, cert_code, issue_time, apll_time, veri_time, veri_pers, veri_if_agree, wiun_opin, note, coll_time, upd_time, rec_pers
        from bis_ttsa_cert_reis_appl
    </sql>

    <select id="selectBisTtsaCertReisApplAll" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertReisAppl" resultMap="BisTtsaCertReisApplResult">
        <include refid="selectBisTtsaCertReisApplVo"/>
        order by coll_time desc
    </select>

    <select id="selectBisTtsaCertReisApplList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertReisAppl" resultMap="BisTtsaCertReisApplResult">
        <include refid="selectBisTtsaCertReisApplVo"/>
        <where>
            <if test="certCode != null and certCode != ''">and cert_code = #{certCode}</if>
            <if test="applWiunCode != null and applWiunCode != ''">and appl_wiun_code = #{applWiunCode}</if>
            <if test="veriIfAgree != null and veriIfAgree != ''">and veri_if_agree = #{veriIfAgree}</if>
        </where>
        order by coll_time desc
    </select>

    <select id="selectBisTtsaCertReisApplByGuid" parameterType="String" resultMap="BisTtsaCertReisApplResult">
        <include refid="selectBisTtsaCertReisApplVo"/>
        where guid = #{guid}
    </select>

    <insert id="insertBisTtsaCertReisAppl" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertReisAppl" useGeneratedKeys="true" keyProperty="guid">
        insert into bis_ttsa_cert_reis_appl (
            guid, appl_wiun_code, cert_code, issue_time, apll_time, veri_time, veri_pers, veri_if_agree, wiun_opin, note, coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{applWiunCode}, #{certCode}, #{issueTime}, #{apllTime}, #{veriTime}, #{veriPers}, #{veriIfAgree}, #{wiunOpin}, #{note}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, #{recPers}
        )
    </insert>

    <update id="updateBisTtsaCertReisAppl" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertReisAppl">
        update bis_ttsa_cert_reis_appl
        <set>
            <if test="applWiunCode != null">appl_wiun_code = #{applWiunCode},</if>
            <if test="certCode != null">cert_code = #{certCode},</if>
            <if test="issueTime != null">issue_time = #{issueTime},</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="note != null">note = #{note},</if>
            upd_time = CURRENT_TIMESTAMP
        </set>
        where guid = #{guid}
    </update>

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

</mapper>
