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

    <resultMap type="TestTaskLog" id="TestTaskLogResult">
        <result property="id"    column="id"    />
        <result property="taskId"    column="task_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="selectTestTaskLogVo">
        select id, task_id, oper_type, oper_detail, oper_user, oper_time from test_task_log
    </sql>

    <select id="selectTestTaskLogList" parameterType="TestTaskLog" resultMap="TestTaskLogResult">
        <include refid="selectTestTaskLogVo"/>
        <where>
            <if test="taskId != null "> and task_id = #{taskId}</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 operUser != ''"> and oper_user = #{operUser}</if>
            <if test="operTime != null "> and oper_time = #{operTime}</if>
        </where>
    </select>

    <select id="selectTestTaskLogById" parameterType="Long" resultMap="TestTaskLogResult">
        <include refid="selectTestTaskLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertTestTaskLog" parameterType="TestTaskLog" useGeneratedKeys="true" keyProperty="id">
        insert into test_task_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskId != null">task_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="taskId != null">#{taskId},</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="updateTestTaskLog" parameterType="TestTaskLog">
        update test_task_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskId != null">task_id = #{taskId},</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="deleteTestTaskLogById" parameterType="Long">
        delete from test_task_log where id = #{id}
    </delete>

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