<?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.BisTtsaCertChaNameMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaName" id="BisTtsaCertChaNameResult">
        <result property="guid" column="guid"/>
        <result property="chaApplGuid" column="cha_appl_guid"/>
        <result property="beforChaName" column="befor_cha_name"/>
        <result property="afterChaName" column="after_cha_name"/>
        <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="ifRepAppr" column="if_rep_appr"/>
    </resultMap>

    <sql id="selectBisTtsaCertChaNameVo">
        select guid, cha_appl_guid, befor_cha_name, after_cha_name, note,
               coll_time, upd_time, rec_pers, if_rep_appr
        from bis_ttsa_cert_cha_name
    </sql>

    <select id="selectBisTtsaCertChaNameByGuid" parameterType="String" resultMap="BisTtsaCertChaNameResult">
        <include refid="selectBisTtsaCertChaNameVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaCertChaNameList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaName" resultMap="BisTtsaCertChaNameResult">
        <include refid="selectBisTtsaCertChaNameVo"/>
        <where>
            <if test="chaApplGuid != null and chaApplGuid != ''">and cha_appl_guid = #{chaApplGuid}</if>
        </where>
    </select>

    <insert id="insertBisTtsaCertChaName" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaName">
        insert into bis_ttsa_cert_cha_name (
            guid, cha_appl_guid, befor_cha_name, after_cha_name, note,
            coll_time, upd_time, rec_pers, if_rep_appr
        ) values (
            #{guid}, #{chaApplGuid}, #{beforChaName}, #{afterChaName}, #{note},
            #{collTime}, #{updTime}, #{recPers}, #{ifRepAppr}
        )
    </insert>

    <update id="updateBisTtsaCertChaName" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaName">
        update bis_ttsa_cert_cha_name
        <set>
            <if test="chaApplGuid != null">cha_appl_guid = #{chaApplGuid},</if>
            <if test="beforChaName != null">befor_cha_name = #{beforChaName},</if>
            <if test="afterChaName != null">after_cha_name = #{afterChaName},</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="ifRepAppr != null">if_rep_appr = #{ifRepAppr},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteBisTtsaCertChaNameByGuid" parameterType="String">
        delete from bis_ttsa_cert_cha_name where guid = #{guid}
    </delete>

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