<?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.BisTtsaCertArrayMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCertArray" id="BisTtsaCertArrayResult">
        <result property="guid" column="guid"/>
        <result property="arrayName" column="array_name"/>
        <result property="ttsaCertType" column="ttsa_cert_type"/>
        <result property="ttsaCertNum" column="ttsa_cert_num"/>
        <result property="grantInst" column="grant_inst"/>
        <result property="issueTime" column="issue_time"/>
        <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"/>
    </resultMap>

    <sql id="selectBisTtsaCertArrayVo">
        select guid, array_name, ttsa_cert_type, ttsa_cert_num, grant_inst,
               issue_time, note, coll_time, upd_time, rec_pers, puno_guid
        from bis_ttsa_cert_array
    </sql>

    <select id="selectBisTtsaCertArrayByGuid" parameterType="String" resultMap="BisTtsaCertArrayResult">
        <include refid="selectBisTtsaCertArrayVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaCertArrayList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertArray" resultMap="BisTtsaCertArrayResult">
        <include refid="selectBisTtsaCertArrayVo"/>
        <where>
            <if test="arrayName != null and arrayName != ''">and array_name like '%' || #{arrayName} || '%'</if>
            <if test="ttsaCertType != null and ttsaCertType != ''">and ttsa_cert_type = #{ttsaCertType}</if>
        </where>
    </select>

    <insert id="insertBisTtsaCertArray" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertArray">
        insert into bis_ttsa_cert_array (
            guid, array_name, ttsa_cert_type, ttsa_cert_num, grant_inst,
            issue_time, note, coll_time, upd_time, rec_pers, puno_guid
        ) values (
            #{guid}, #{arrayName}, #{ttsaCertType}, #{ttsaCertNum}, #{grantInst},
            #{issueTime}, #{note}, #{collTime}, #{updTime}, #{recPers}, #{punoGuid}
        )
    </insert>

    <update id="updateBisTtsaCertArray" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertArray">
        update bis_ttsa_cert_array
        <set>
            <if test="arrayName != null">array_name = #{arrayName},</if>
            <if test="ttsaCertType != null">ttsa_cert_type = #{ttsaCertType},</if>
            <if test="ttsaCertNum != null">ttsa_cert_num = #{ttsaCertNum},</if>
            <if test="grantInst != null">grant_inst = #{grantInst},</if>
            <if test="issueTime != null">issue_time = #{issueTime},</if>
            <if test="note != null">note = #{note},</if>
            <if test="updTime != null">upd_time = #{updTime},</if>
            <if test="recPers != null">rec_pers = #{recPers},</if>
            <if test="punoGuid != null">puno_guid = #{punoGuid},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteBisTtsaCertArrayByGuid" parameterType="String">
        delete from bis_ttsa_cert_array where guid = #{guid}
    </delete>

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