<?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.cn.fdapfe.biz.mapper.WorkflowNodeMapper">
    
    <resultMap type="WorkflowNode" id="WorkflowNodeResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="type"    column="type"    />
        <result property="subType"    column="sub_type"    />
        <result property="taskId"    column="task_id"    />
        <result property="remark"    column="remark"    />
        <result property="startTime"    column="start_time"    />
        <result property="endTime"    column="end_time"    />
        <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="selectWorkflowNodeVo">
        select id, name, type, sub_type, task_id, remark, start_time, end_time, create_by, create_time, update_by, update_time from biz_workflow_node
    </sql>

    <select id="selectWorkflowNodeList" parameterType="WorkflowNode" resultMap="WorkflowNodeResult">
        <include refid="selectWorkflowNodeVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="subType != null  and subType != ''"> and sub_type = #{subType}</if>
            <if test="taskId != null "> and task_id = #{taskId}</if>
            <if test="startTime != null "> and start_time = #{startTime}</if>
            <if test="endTime != null "> and end_time = #{endTime}</if>
        </where>
    </select>
    
    <select id="selectWorkflowNodeById" parameterType="Long" resultMap="WorkflowNodeResult">
        <include refid="selectWorkflowNodeVo"/>
        where id = #{id}
    </select>

    <insert id="insertWorkflowNode" parameterType="WorkflowNode" useGeneratedKeys="true" keyProperty="id">
        insert into biz_workflow_node
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null">name,</if>
            <if test="type != null">type,</if>
            <if test="subType != null">sub_type,</if>
            <if test="taskId != null">task_id,</if>
            <if test="remark != null">remark,</if>
            <if test="startTime != null">start_time,</if>
            <if test="endTime != null">end_time,</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="name != null">#{name},</if>
            <if test="type != null">#{type},</if>
            <if test="subType != null">#{subType},</if>
            <if test="taskId != null">#{taskId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="endTime != null">#{endTime},</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="updateWorkflowNode" parameterType="WorkflowNode">
        update biz_workflow_node
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="type != null">type = #{type},</if>
            <if test="subType != null">sub_type = #{subType},</if>
            <if test="taskId != null">task_id = #{taskId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="endTime != null">end_time = #{endTime},</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 id = #{id}
    </update>

    <delete id="deleteWorkflowNodeById" parameterType="Long">
        delete from biz_workflow_node where id = #{id}
    </delete>

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