<?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.test.test.mapper.PerformanceTestCaseMapper">

    <resultMap type="PerformanceTestCase" id="PerformanceTestCaseResult">
        <result property="id"    column="id"    />
        <result property="performanceId"    column="performance_id"    />
        <result property="testCaseId"    column="test_case_id"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectPerformanceTestCaseVo">
        select id, performance_id, test_case_id, status from performance_test_case
    </sql>

    <select id="selectPerformanceTestCaseList" parameterType="PerformanceTestCase" resultMap="PerformanceTestCaseResult">
        <include refid="selectPerformanceTestCaseVo"/>
        <where>
            <if test="performanceId != null "> and performance_id = #{performanceId}</if>
            <if test="testCaseId != null "> and test_case_id = #{testCaseId}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>

    <select id="selectPerformanceTestCaseById" parameterType="Long" resultMap="PerformanceTestCaseResult">
        <include refid="selectPerformanceTestCaseVo"/>
        where id = #{id}
    </select>

    <insert id="insertPerformanceTestCase" parameterType="PerformanceTestCase">
        insert into performance_test_case
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="performanceId != null">performance_id,</if>
            <if test="testCaseId != null">test_case_id,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="performanceId != null">#{performanceId},</if>
            <if test="testCaseId != null">#{testCaseId},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updatePerformanceTestCase" parameterType="PerformanceTestCase">
        update performance_test_case
        <trim prefix="SET" suffixOverrides=",">
            <if test="performanceId != null">performance_id = #{performanceId},</if>
            <if test="testCaseId != null">test_case_id = #{testCaseId},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePerformanceTestCaseById" parameterType="Long">
        delete from performance_test_case where performance_id = #{id}
    </delete>

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