<?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.cmvr.aima.mapper.AimaTaskTestCaseMapper">

    <insert id="batchInsertTaskTestCase">
        INSERT INTO aima_task_test_case (task_id, test_case_id, sort_order) VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.taskId}, #{item.testCaseId}, #{item.sortOrder})
        </foreach>
    </insert>

    <delete id="deleteTaskTestCaseByTaskId" parameterType="String">
        DELETE FROM aima_task_test_case WHERE task_id = #{taskId}
    </delete>

    <select id="selectTestCaseIdsByTaskId" parameterType="String" resultType="String">
        SELECT test_case_id FROM aima_task_test_case 
        WHERE task_id = #{taskId} 
        ORDER BY sort_order
    </select>

    <delete id="deleteTaskTestCaseByTaskIds" parameterType="String">
        DELETE FROM aima_task_test_case WHERE task_id IN
        <foreach item="taskId" collection="array" open="(" separator="," close=")">
            #{taskId}
        </foreach>
    </delete>

</mapper>
