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

    <resultMap type="TestCaseLog" id="TestCaseLogResult">
        <result property="id" column="id"/>
        <result property="caseId" column="case_id"/>
        <result property="operType" column="oper_type"/>
        <result property="operDetail" column="oper_detail"/>
        <result property="operUser" column="oper_user"/>
        <result property="operTime" column="oper_time"/>
    </resultMap>

    <sql id="selectTestCaseLogVo">
        select id, case_id, oper_type, oper_detail, oper_user, oper_time
        from test_case_log
    </sql>

    <select id="selectTestCaseLogList" parameterType="TestCaseLog" resultMap="TestCaseLogResult">
        <include refid="selectTestCaseLogVo"/>
        <where>
            <if test="caseId != null  and caseId != ''">and case_id = #{caseId}</if>
            <if test="operType != null  and operType != ''">and oper_type = #{operType}</if>
            <if test="operDetail != null  and operDetail != ''">and oper_detail = #{operDetail}</if>
            <if test="operUser != null ">and oper_user = #{operUser}</if>
            <if test="operTime != null ">and oper_time = #{operTime}</if>
        </where>
    </select>

    <select id="selectTestCaseLogById" parameterType="Long" resultMap="TestCaseLogResult">
        <include refid="selectTestCaseLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertTestCaseLog" parameterType="TestCaseLog" useGeneratedKeys="true" keyProperty="id">
        insert into test_case_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="caseId != null">case_id,</if>
            <if test="operType != null">oper_type,</if>
            <if test="operDetail != null">oper_detail,</if>
            <if test="operUser != null">oper_user,</if>
            <if test="operTime != null">oper_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="caseId != null">#{caseId},</if>
            <if test="operType != null">#{operType},</if>
            <if test="operDetail != null">#{operDetail},</if>
            <if test="operUser != null">#{operUser},</if>
            <if test="operTime != null">#{operTime},</if>
        </trim>
    </insert>

    <update id="updateTestCaseLog" parameterType="TestCaseLog">
        update test_case_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="caseId != null">case_id = #{caseId},</if>
            <if test="operType != null">oper_type = #{operType},</if>
            <if test="operDetail != null">oper_detail = #{operDetail},</if>
            <if test="operUser != null">oper_user = #{operUser},</if>
            <if test="operTime != null">oper_time = #{operTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTestCaseLogById" parameterType="Long">
        delete
        from test_case_log
        where id = #{id}
    </delete>

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