<?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.microservices.pms.project.mapper.PmsProjectTestReportSheetMapper">
    
    <resultMap type="PmsProjectTestReportSheet" id="PmsProjectTestReportSheetResult">
        <result property="projectTestReportId"    column="project_test_report_id"    />
        <result property="projectTestSheetId"    column="project_test_sheet_id"    />
    </resultMap>

    <sql id="selectPmsProjectTestReportSheetVo">
        select project_test_report_id, project_test_sheet_id from pms_project_test_report_sheet
    </sql>

    <select id="selectPmsProjectTestReportSheetList" parameterType="PmsProjectTestReportSheet" resultMap="PmsProjectTestReportSheetResult">
        <include refid="selectPmsProjectTestReportSheetVo"/>
        <where>
            <if test="projectTestReportId != null">project_test_report_id = #{projectTestReportId},</if>
        </where>
    </select>
    
    <select id="selectPmsProjectTestReportSheetByProjectTestReportId" parameterType="Long" resultMap="PmsProjectTestReportSheetResult">
        <include refid="selectPmsProjectTestReportSheetVo"/>
        where project_test_report_id = #{projectTestReportId}
    </select>
        
    <insert id="insertPmsProjectTestReportSheet" parameterType="PmsProjectTestReportSheet">
        insert into pms_project_test_report_sheet
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectTestReportId != null">project_test_report_id,</if>
            <if test="projectTestSheetId != null">project_test_sheet_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectTestReportId != null">#{projectTestReportId},</if>
            <if test="projectTestSheetId != null">#{projectTestSheetId},</if>
         </trim>
    </insert>

    <update id="updatePmsProjectTestReportSheet" parameterType="PmsProjectTestReportSheet">
        update pms_project_test_report_sheet
        <trim prefix="SET" suffixOverrides=",">
            <if test="projectTestSheetId != null">project_test_sheet_id = #{projectTestSheetId},</if>
        </trim>
        where project_test_report_id = #{projectTestReportId}
    </update>

    <delete id="deletePmsProjectTestReportSheetByProjectTestReportId" parameterType="Long">
        delete from pms_project_test_report_sheet where project_test_report_id = #{projectTestReportId}
    </delete>

    <delete id="deletePmsProjectTestReportSheetByProjectTestReportIds" parameterType="String">
        delete from pms_project_test_report_sheet where project_test_report_id in 
        <foreach item="projectTestReportId" collection="array" open="(" separator="," close=")">
            #{projectTestReportId}
        </foreach>
    </delete>
</mapper>