<?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.BisTtsaCertMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCert" id="BisTtsaCertResult">
        <result property="guid" column="guid"/>
        <result property="pGuid" column="p_guid"/>
        <result property="arrayGuid" column="array_guid"/>
        <result property="certCode" column="cert_code"/>
        <result property="persTtsGuid" column="pers_tts_guid"/>
        <result property="ttsaGuid" column="ttsa_guid"/>
        <result property="ttsaCertType" column="ttsa_cert_type"/>
        <result property="issueTime" column="issue_time"/>
        <result property="issueOrgGuid" column="issue_org_guid"/>
        <result property="certExpiTime" column="cert_expi_time"/>
        <result property="grantInst" column="grant_inst"/>
        <result property="certStat" column="cert_stat"/>
        <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="selectBisTtsaCertVo">
        select guid, p_guid, array_guid, cert_code, pers_tts_guid,
               ttsa_guid, ttsa_cert_type, issue_time, issue_org_guid, cert_expi_time,
               grant_inst, cert_stat, note, coll_time, upd_time, rec_pers
        from bis_ttsa_cert
    </sql>

    <select id="selectBisTtsaCertByGuid" parameterType="String" resultMap="BisTtsaCertResult">
        <include refid="selectBisTtsaCertVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaCertList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCert" resultMap="BisTtsaCertResult">
        <include refid="selectBisTtsaCertVo"/>
        <where>
            <if test="certCode != null and certCode != ''">and cert_code = #{certCode}</if>
            <if test="ttsaCertType != null and ttsaCertType != ''">and ttsa_cert_type = #{ttsaCertType}</if>
            <if test="certStat != null and certStat != ''">and cert_stat = #{certStat}</if>
            <if test="persTtsGuid != null and persTtsGuid != ''">and pers_tts_guid = #{persTtsGuid}</if>
        </where>
    </select>

    <insert id="insertBisTtsaCert" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCert">
        insert into bis_ttsa_cert (
            guid, p_guid, array_guid, cert_code, pers_tts_guid,
            ttsa_guid, ttsa_cert_type, issue_time, issue_org_guid, cert_expi_time,
            grant_inst, cert_stat, note, coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{pGuid}, #{arrayGuid}, #{certCode}, #{persTtsGuid},
            #{ttsaGuid}, #{ttsaCertType}, #{issueTime}, #{issueOrgGuid}, #{certExpiTime},
            #{grantInst}, #{certStat}, #{note}, #{collTime}, #{updTime}, #{recPers}
        )
    </insert>

    <update id="updateBisTtsaCert" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCert">
        update bis_ttsa_cert
        <set>
            <if test="pGuid != null">p_guid = #{pGuid},</if>
            <if test="arrayGuid != null">array_guid = #{arrayGuid},</if>
            <if test="certCode != null">cert_code = #{certCode},</if>
            <if test="persTtsGuid != null">pers_tts_guid = #{persTtsGuid},</if>
            <if test="ttsaGuid != null">ttsa_guid = #{ttsaGuid},</if>
            <if test="ttsaCertType != null">ttsa_cert_type = #{ttsaCertType},</if>
            <if test="issueTime != null">issue_time = #{issueTime},</if>
            <if test="issueOrgGuid != null">issue_org_guid = #{issueOrgGuid},</if>
            <if test="certExpiTime != null">cert_expi_time = #{certExpiTime},</if>
            <if test="grantInst != null">grant_inst = #{grantInst},</if>
            <if test="certStat != null">cert_stat = #{certStat},</if>
            <if test="note != null">note = #{note},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null">rec_pers = #{recPers},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteBisTtsaCertByGuid" parameterType="String">
        delete from bis_ttsa_cert where guid = #{guid}
    </delete>

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