<?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.BisTtsaDesignExamRelMapper">
    <resultMap type="com.goldenwater.slaj.ttsa.domain.BisTtsaDesignExamRel" id="BisTtsaDesignExamRelResult">
        <result property="guid" column="guid"/>
        <result property="designGuid" column="design_guid"/>
        <result property="examGuid" column="exam_guid"/>
        <result property="paperGuid" column="paper_guid"/>
        <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="selectBisTtsaDesignExamRelVo">
        select guid, design_guid, exam_guid, paper_guid, note,
               coll_time, upd_time, rec_pers
        from bis_ttsa_design_exam_rel
    </sql>

    <select id="selectBisTtsaDesignExamRelByGuid" parameterType="String" resultMap="BisTtsaDesignExamRelResult">
        <include refid="selectBisTtsaDesignExamRelVo"/> where guid = #{guid}
    </select>

    <select id="selectBisTtsaDesignExamRelList" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesignExamRel" resultMap="BisTtsaDesignExamRelResult">
        <include refid="selectBisTtsaDesignExamRelVo"/>
        <where>
            <if test="designGuid != null and designGuid != ''">and design_guid = #{designGuid}</if>
            <if test="examGuid != null and examGuid != ''">and exam_guid = #{examGuid}</if>
        </where>
    </select>

    <insert id="insertBisTtsaDesignExamRel" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesignExamRel">
        insert into bis_ttsa_design_exam_rel (
            guid, design_guid, exam_guid, paper_guid, note,
            coll_time, upd_time, rec_pers
        ) values (
            #{guid}, #{designGuid}, #{examGuid}, #{paperGuid}, #{note},
            #{collTime}, #{updTime}, #{recPers}
        )
    </insert>

    <update id="updateBisTtsaDesignExamRel" parameterType="com.goldenwater.slaj.ttsa.domain.BisTtsaDesignExamRel">
        update bis_ttsa_design_exam_rel
        <set>
            <if test="designGuid != null">design_guid = #{designGuid},</if>
            <if test="examGuid != null">exam_guid = #{examGuid},</if>
            <if test="paperGuid != null">paper_guid = #{paperGuid},</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="deleteBisTtsaDesignExamRelByGuid" parameterType="String">
        delete from bis_ttsa_design_exam_rel where guid = #{guid}
    </delete>

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