<?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.BisTtsaTrainPersMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaTrainPers" id="BisTtsaTrainPersResult">
        <result property="guid" column="guid"/>
        <result property="ttsaCertGuid" column="ttsa_cert_guid"/>
        <result property="persName" column="pers_name"/>
        <result property="persType" column="pers_type"/>
        <result property="ttsaTrainGuid" column="ttsa_train_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="trainResu" column="train_resu"/>
    </resultMap>

    <sql id="selectBisTtsaTrainPersVo">
        select guid, ttsa_cert_guid, pers_name, pers_type, ttsa_train_guid,
               note, coll_time, upd_time, rec_pers, train_resu
        from bis_ttsa_train_pers
    </sql>

    <select id="selectBisTtsaTrainPersByGuid" parameterType="String" resultMap="BisTtsaTrainPersResult">
        <include refid="selectBisTtsaTrainPersVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaTrainPersList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaTrainPers" resultMap="BisTtsaTrainPersResult">
        <include refid="selectBisTtsaTrainPersVo"/>
        <where>
            <if test="ttsaTrainGuid != null and ttsaTrainGuid != ''">and ttsa_train_guid = #{ttsaTrainGuid}</if>
            <if test="persType != null and persType != ''">and pers_type = #{persType}</if>
            <if test="persName != null and persName != ''">and pers_name like concat('%', #{persName}, '%')</if>
        </where>
    </select>

    <insert id="insertBisTtsaTrainPers" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaTrainPers">
        insert into bis_ttsa_train_pers (
            guid, ttsa_cert_guid, pers_name, pers_type, ttsa_train_guid,
            note, coll_time, upd_time, rec_pers, train_resu
        ) values (
            #{guid}, #{ttsaCertGuid}, #{persName}, #{persType}, #{ttsaTrainGuid},
            #{note}, #{collTime}, #{updTime}, #{recPers}, #{trainResu}
        )
    </insert>

    <update id="updateBisTtsaTrainPers" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaTrainPers">
        update bis_ttsa_train_pers
        <set>
            <if test="ttsaCertGuid != null">ttsa_cert_guid = #{ttsaCertGuid},</if>
            <if test="persName != null">pers_name = #{persName},</if>
            <if test="persType != null">pers_type = #{persType},</if>
            <if test="ttsaTrainGuid != null">ttsa_train_guid = #{ttsaTrainGuid},</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="trainResu != null">train_resu = #{trainResu},</if>
        </set>
        where guid = #{guid}
    </update>

    <delete id="deleteBisTtsaTrainPersByGuid" parameterType="String">
        delete from bis_ttsa_train_pers where guid = #{guid}
    </delete>

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