<?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.BisTtsaCertChaCompMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaComp" id="BisTtsaCertChaCompResult">
        <result property="guid" column="guid"/>
        <result property="chaApplGuid" column="cha_appl_guid"/>
        <result property="beforWiunGuid" column="befor_wiun_guid"/>
        <result property="beforCertCode" column="befor_cert_code"/>
        <result property="beforStartTime" column="befor_start_time"/>
        <result property="beforEndTime" column="befor_end_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="beforWiunName" column="befor_wiun_name"/>
        <result property="beforCertType" column="befor_cert_type"/>
    </resultMap>

    <sql id="selectBisTtsaCertChaCompVo">
        select guid, cha_appl_guid, befor_wiun_guid, befor_cert_code, befor_start_time,
               befor_end_time, note, coll_time, upd_time, rec_pers, befor_wiun_name, befor_cert_type
        from bis_ttsa_cert_cha_comp
    </sql>

    <select id="selectBisTtsaCertChaCompByGuid" parameterType="String" resultMap="BisTtsaCertChaCompResult">
        <include refid="selectBisTtsaCertChaCompVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaCertChaCompList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaComp" resultMap="BisTtsaCertChaCompResult">
        <include refid="selectBisTtsaCertChaCompVo"/>
        <where>
            <if test="chaApplGuid != null and chaApplGuid != ''">and cha_appl_guid = #{chaApplGuid}</if>
        </where>
    </select>

    <insert id="insertBisTtsaCertChaComp" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaComp">
        insert into bis_ttsa_cert_cha_comp (
            guid, cha_appl_guid, befor_wiun_guid, befor_cert_code, befor_start_time,
            befor_end_time, note, coll_time, upd_time, rec_pers, befor_wiun_name, befor_cert_type
        ) values (
            #{guid}, #{chaApplGuid}, #{beforWiunGuid}, #{beforCertCode}, #{beforStartTime},
            #{beforEndTime}, #{note}, #{collTime}, #{updTime}, #{recPers}, #{beforWiunName}, #{beforCertType}
        )
    </insert>

    <update id="updateBisTtsaCertChaComp" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaCertChaComp">
        update bis_ttsa_cert_cha_comp
        <set>
            <if test="chaApplGuid != null">cha_appl_guid = #{chaApplGuid},</if>
            <if test="beforWiunGuid != null">befor_wiun_guid = #{beforWiunGuid},</if>
            <if test="beforCertCode != null">befor_cert_code = #{beforCertCode},</if>
            <if test="beforStartTime != null">befor_start_time = #{beforStartTime},</if>
            <if test="beforEndTime != null">befor_end_time = #{beforEndTime},</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="beforWiunName != null">befor_wiun_name = #{beforWiunName},</if>
            <if test="beforCertType != null">befor_cert_type = #{beforCertType},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteBisTtsaCertChaCompByGuid" parameterType="String">
        delete from bis_ttsa_cert_cha_comp where guid = #{guid}
    </delete>

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