<?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.PmsProjectTestcaseStepMapper">

    <resultMap type="PmsProjectTestcaseStep" id="PmsProjectTestcaseStepResult">
        <result property="id" column="id"/>
        <result property="index" column="index"/>
        <result property="content" column="content"/>
        <result property="expectedResult" column="expected_result"/>
        <result property="pmsTestcaseId" column="pms_testcase_id"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="createTime" column="create_time"/>
        <result property="createBy" column="create_by"/>
        <result property="delFlag" column="del_flag"/>
        <result property="reservedField1" column="reserved_field_1"/>
        <result property="reservedField2" column="reserved_field_2"/>
    </resultMap>

    <sql id="selectPmsProjectTestcaseStepVo">
        select id,
               `index`,
               content,
               expected_result,
               pms_testcase_id,
               update_time,
               update_by,
               create_time,
               create_by,
               del_flag,
               reserved_field_1,
               reserved_field_2
        from pms_project_testcase_step
    </sql>

    <select id="selectPmsProjectTestcaseStepList" parameterType="PmsProjectTestcaseStep"
            resultMap="PmsProjectTestcaseStepResult">
        <include refid="selectPmsProjectTestcaseStepVo"/>
        <where>
            <if test="index != null ">and `index` = #{index}</if>
            <if test="content != null  and content != ''">and content = #{content}</if>
            <if test="expectedResult != null  and expectedResult != ''">and expected_result = #{expectedResult}</if>
            <if test="pmsTestcaseId != null ">and pms_testcase_id = #{pmsTestcaseId}</if>
            <if test="reservedField1 != null  and reservedField1 != ''">and reserved_field_1 = #{reservedField1}</if>
            <if test="reservedField2 != null  and reservedField2 != ''">and reserved_field_2 = #{reservedField2}</if>
        </where>
        order by `index`
    </select>

    <select id="selectPmsProjectTestcaseStepById" parameterType="Long" resultMap="PmsProjectTestcaseStepResult">
        <include refid="selectPmsProjectTestcaseStepVo"/>
        where id = #{id}
    </select>
    <select id="selectPmsProjectTestcaseStepByIndexAndTestcaseId" resultMap="PmsProjectTestcaseStepResult">
        <include refid="selectPmsProjectTestcaseStepVo"/>
        where `index` = #{index}
        and pms_testcase_id=#{testcaseId}
    </select>

    <insert id="insertPmsProjectTestcaseStep" parameterType="PmsProjectTestcaseStep" useGeneratedKeys="true"
            keyProperty="id">
        insert into pms_project_testcase_step
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="index != null">`index`,</if>
            <if test="content != null and content != ''">content,</if>
            <if test="expectedResult != null">expected_result,</if>
            <if test="pmsTestcaseId != null">pms_testcase_id,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="reservedField1 != null">reserved_field_1,</if>
            <if test="reservedField2 != null">reserved_field_2,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="index != null">#{index},</if>
            <if test="content != null and content != ''">#{content},</if>
            <if test="expectedResult != null">#{expectedResult},</if>
            <if test="pmsTestcaseId != null">#{pmsTestcaseId},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="reservedField1 != null">#{reservedField1},</if>
            <if test="reservedField2 != null">#{reservedField2},</if>
        </trim>
    </insert>

    <update id="updatePmsProjectTestcaseStep" parameterType="PmsProjectTestcaseStep">
        update pms_project_testcase_step
        <trim prefix="SET" suffixOverrides=",">
            <if test="index != null">`index` = #{index},</if>
            <if test="content != null and content != ''">content = #{content},</if>
            <if test="expectedResult != null">expected_result = #{expectedResult},</if>
            <if test="pmsTestcaseId != null">pms_testcase_id = #{pmsTestcaseId},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="reservedField1 != null">reserved_field_1 = #{reservedField1},</if>
            <if test="reservedField2 != null">reserved_field_2 = #{reservedField2},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePmsProjectTestcaseStepById" parameterType="Long">
        delete
        from pms_project_testcase_step
        where id = #{id}
    </delete>

    <delete id="deletePmsProjectTestcaseStepByIds" parameterType="String">
        delete from pms_project_testcase_step where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deletePmsProjectTestcaseStepByTestcaseId">
        delete
        from pms_project_testcase_step
        where pms_testcase_id = #{pmsTestcaseId}
    </delete>
</mapper>