<?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.BisTtsaDesigndetailMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaDesigndetail" id="BisTtsaDesigndetailResult">
        <result property="guid" column="guid"/>
        <result property="designGuid" column="design_guid"/>
        <result property="persTtsGuid" column="pers_tts_guid"/>
        <result property="persName" column="pers_name"/>
        <result property="persType" column="pers_type"/>
        <result property="examType" column="exam_type"/>
        <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="selectBisTtsaDesigndetailVo">
        select guid, design_guid, pers_tts_guid, pers_name, pers_type,
               exam_type, note, coll_time, upd_time, rec_pers
        from bis_ttsa_designdetail
    </sql>

    <select id="selectBisTtsaDesigndetailByGuid" parameterType="String" resultMap="BisTtsaDesigndetailResult">
        <include refid="selectBisTtsaDesigndetailVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaDesigndetailList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesigndetail" resultMap="BisTtsaDesigndetailResult">
        <include refid="selectBisTtsaDesigndetailVo"/>
        <where>
            <if test="designGuid != null and designGuid != ''">and design_guid = #{designGuid}</if>
            <if test="persName != null and persName != ''">and pers_name like concat('%', #{persName}, '%')</if>
        </where>
    </select>

    <insert id="insertBisTtsaDesigndetail" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesigndetail">
        insert into bis_ttsa_designdetail (
            guid, design_guid, pers_tts_guid, pers_name, pers_type,
            exam_type, note, coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{designGuid}, #{persTtsGuid}, #{persName}, #{persType},
            #{examType}, #{note}, #{collTime}, #{updTime}, #{recPers}
        )
    </insert>

    <update id="updateBisTtsaDesigndetail" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesigndetail">
        update bis_ttsa_designdetail
        <set>
            <if test="designGuid != null">design_guid = #{designGuid},</if>
            <if test="persTtsGuid != null">pers_tts_guid = #{persTtsGuid},</if>
            <if test="persName != null">pers_name = #{persName},</if>
            <if test="persType != null">pers_type = #{persType},</if>
            <if test="examType != null">exam_type = #{examType},</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="deleteBisTtsaDesigndetailByGuid" parameterType="String">
        delete from bis_ttsa_designdetail where guid = #{guid}
    </delete>

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