<?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.zehong.system.mapper.TTaskRecordMapper">

    <resultMap type="TTaskRecord" id="TTaskRecordResult">
        <result property="taskRecordId"    column="task_record_id"    />
        <result property="operator"    column="operator"    />
        <result property="processesRelationId"    column="processes_relation_id"    />
        <result property="processesName"    column="processes_name"    />
        <result property="createTime"    column="create_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectTTaskRecordVo">
        select task_record_id, operator, processes_relation_id, processes_name, create_time, is_del from t_task_record
    </sql>

    <select id="selectTTaskRecordList" parameterType="TTaskRecord" resultMap="TTaskRecordResult">
        <include refid="selectTTaskRecordVo"/>
        <where>
            <if test="operator != null "> and operator = #{operator}</if>
            <if test="processesRelationId != null "> and processes_relation_id = #{processesRelationId}</if>
            <if test="processesName != null  and processesName != ''"> and processes_name like concat('%', #{processesName}, '%')</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
        order by task_record_id desc
    </select>

    <select id="selectTTaskRecordById" parameterType="Long" resultMap="TTaskRecordResult">
        <include refid="selectTTaskRecordVo"/>
        where task_record_id = #{taskRecordId}
    </select>

    <insert id="insertTTaskRecord" parameterType="TTaskRecord" useGeneratedKeys="true" keyProperty="taskRecordId">
        insert into t_task_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="operator != null">operator,</if>
            <if test="processesRelationId != null">processes_relation_id,</if>
            <if test="processesName != null">processes_name,</if>
            <if test="createTime != null">create_time,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="operator != null">#{operator},</if>
            <if test="processesRelationId != null">#{processesRelationId},</if>
            <if test="processesName != null">#{processesName},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateTTaskRecord" parameterType="TTaskRecord">
        update t_task_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="operator != null">operator = #{operator},</if>
            <if test="processesRelationId != null">processes_relation_id = #{processesRelationId},</if>
            <if test="processesName != null">processes_name = #{processesName},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
        </trim>
        where task_record_id = #{taskRecordId}
    </update>

    <delete id="deleteTTaskRecordById" parameterType="Long">
        delete from t_task_record where task_record_id = #{taskRecordId}
    </delete>

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