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

    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCertRevAppl" id="BisTtsaCertRevApplResult">
        <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="applTime" column="appl_time"/>
        <result property="revReas" column="rev_reas"/>
        <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="punoGuid" column="puno_guid"/>
        <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="flowStat" column="flow_stat"/>
        <result property="ifRep" column="if_rep"/>
    </resultMap>

    <sql id="selectBisTtsaCertRevApplVo">
        select guid, ttsa_cert_guid, appl_org_guid, cert_code, appl_time, rev_reas, veri_time, veri_pers, veri_if_agree, wiun_opin, puno_guid, note, coll_time, upd_time, rec_pers, flow_stat, if_rep
        from bis_ttsa_cert_rev_appl
    </sql>

    <select id="selectBisTtsaCertRevApplAll" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertRevAppl" resultMap="BisTtsaCertRevApplResult">
        <include refid="selectBisTtsaCertRevApplVo"/>
        order by coll_time desc
    </select>

    <select id="selectBisTtsaCertRevApplList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertRevAppl" resultMap="BisTtsaCertRevApplResult">
        <include refid="selectBisTtsaCertRevApplVo"/>
        <where>
            <if test="ttsaCertGuid != null and ttsaCertGuid != ''">and ttsa_cert_guid = #{ttsaCertGuid}</if>
            <if test="veriIfAgree != null and veriIfAgree != ''">and veri_if_agree = #{veriIfAgree}</if>
            <if test="flowStat != null and flowStat != ''">and flow_stat = #{flowStat}</if>
        </where>
        order by coll_time desc
    </select>

    <select id="selectBisTtsaCertRevApplByGuid" parameterType="String" resultMap="BisTtsaCertRevApplResult">
        <include refid="selectBisTtsaCertRevApplVo"/>
        where guid = #{guid}
    </select>

    <insert id="insertBisTtsaCertRevAppl" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertRevAppl" useGeneratedKeys="true" keyProperty="guid">
        insert into bis_ttsa_cert_rev_appl (
            guid, ttsa_cert_guid, appl_org_guid, cert_code, appl_time, rev_reas, veri_time, veri_pers, veri_if_agree, wiun_opin, puno_guid, note, coll_time, upd_time, rec_pers, flow_stat, if_rep
        ) values (
            #{guid}, #{ttsaCertGuid}, #{applOrgGuid}, #{certCode}, #{applTime}, #{revReas}, #{veriTime}, #{veriPers}, #{veriIfAgree}, #{wiunOpin}, #{punoGuid}, #{note}, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, #{recPers}, #{flowStat}, #{ifRep}
        )
    </insert>

    <update id="updateBisTtsaCertRevAppl" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertRevAppl">
        update bis_ttsa_cert_rev_appl
        <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="applTime != null">appl_time = #{applTime},</if>
            <if test="revReas != null">rev_reas = #{revReas},</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="punoGuid != null">puno_guid = #{punoGuid},</if>
            <if test="note != null">note = #{note},</if>
            <if test="flowStat != null">flow_stat = #{flowStat},</if>
            <if test="ifRep != null">if_rep = #{ifRep},</if>
            upd_time = CURRENT_TIMESTAMP
        </set>
        where guid = #{guid}
    </update>

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

</mapper>
