<?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.xinda.itsm.mapper.ProcessInfoMapper">
    
    <resultMap type="ProcessInfo" id="ProcessInfoResult">
        <result property="processId"    column="process_id"    />
        <result property="eventName"    column="event_name"    />
        <result property="eventType"    column="event_type"    />
        <result property="touchTime"    column="touch_time"    />
        <result property="handleResult"    column="handle_result"    />
        <result property="handlePerson"    column="handle_person"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectProcessInfoVo">
        select process_id, event_name, event_type, touch_time, handle_result, handle_person, remark, create_by, create_time, update_by, update_time from process_info
    </sql>

    <select id="selectProcessInfoList" parameterType="ProcessInfo" resultMap="ProcessInfoResult">
        <include refid="selectProcessInfoVo"/>
        <where>  
            <if test="eventName != null  and eventName != ''"> and event_name like concat('%', #{eventName}, '%')</if>
            <if test="eventType != null  and eventType != ''"> and event_type = #{eventType}</if>
            <if test="touchTime != null "> and touch_time = #{touchTime}</if>
            <if test="handleResult != null  and handleResult != ''"> and handle_result = #{handleResult}</if>
            <if test="handlePerson != null "> and handle_person = #{handlePerson}</if>
        </where>
    </select>
    
    <select id="selectProcessInfoByProcessId" parameterType="Long" resultMap="ProcessInfoResult">
        <include refid="selectProcessInfoVo"/>
        where process_id = #{processId}
    </select>
        
    <insert id="insertProcessInfo" parameterType="ProcessInfo">
        insert into process_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="processId != null">process_id,</if>
            <if test="eventName != null">event_name,</if>
            <if test="eventType != null">event_type,</if>
            <if test="touchTime != null">touch_time,</if>
            <if test="handleResult != null">handle_result,</if>
            <if test="handlePerson != null">handle_person,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="processId != null">#{processId},</if>
            <if test="eventName != null">#{eventName},</if>
            <if test="eventType != null">#{eventType},</if>
            <if test="touchTime != null">#{touchTime},</if>
            <if test="handleResult != null">#{handleResult},</if>
            <if test="handlePerson != null">#{handlePerson},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateProcessInfo" parameterType="ProcessInfo">
        update process_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="eventName != null">event_name = #{eventName},</if>
            <if test="eventType != null">event_type = #{eventType},</if>
            <if test="touchTime != null">touch_time = #{touchTime},</if>
            <if test="handleResult != null">handle_result = #{handleResult},</if>
            <if test="handlePerson != null">handle_person = #{handlePerson},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where process_id = #{processId}
    </update>

    <delete id="deleteProcessInfoByProcessId" parameterType="Long">
        delete from process_info where process_id = #{processId}
    </delete>

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