<?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.ruoyi.execution.produce.dispersed.mapper.BpmExecuteNodeMapper">
    
    <resultMap type="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNode" id="BpmExecuteNodeResult">
        <result property="id"    column="id"    />
        <result property="taskProcessKey"    column="task_process_key"    />
        <result property="taskNodeKey"    column="task_node_key"    />
        <result property="taskNodeName"    column="task_node_name"    />
        <result property="taskNodeFormKey"    column="task_node_form_key"    />
        <result property="taskNodeType"    column="task_node_type"    />
        <result property="taskNodeBefore"    column="task_node_before"    />
        <result property="taskNodeAfter"    column="task_node_after"    />
        <result property="taskNodeRolePermission"    column="task_node_role_permission"    />
        <result property="taskRemark"    column="task_remark"    />
        <result property="taskNodeNumber"    column="task_node_number"    />
        <result property="taskNodeWeight"    column="task_node_weight"    />
        <result property="taskNodeState"    column="task_node_state"    />
        <result property="taskPriority"    column="task_priority"    />
        <result property="task1"    column="task1"    />
        <result property="task2"    column="task2"    />
        <result property="task3"    column="task3"    />
        <result property="task4"    column="task4"    />
        <result property="task5"    column="task5"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createById"    column="create_by_id"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectBpmExecuteNodeVo">
        select id, task_process_key, task_node_key, task_node_name, task_node_form_key, task_node_type, task_node_before, task_node_after, task_node_role_permission, task_remark, task_node_number, task_node_weight, task_node_state, task_priority, task1, task2, task3, task4, task5, del_flag, create_by_id, create_by, create_time from bpm_execute_node
    </sql>

    <select id="selectBpmExecuteNodeList" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNode" resultMap="BpmExecuteNodeResult">
        <include refid="selectBpmExecuteNodeVo"/>
        <where>  
            <if test="taskProcessKey != null  and taskProcessKey != ''"> and task_process_key = #{taskProcessKey}</if>
            <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
            <if test="taskNodeName != null  and taskNodeName != ''"> and task_node_name like concat('%', #{taskNodeName}, '%')</if>
            <if test="taskNodeFormKey != null  and taskNodeFormKey != ''"> and task_node_form_key = #{taskNodeFormKey}</if>
            <if test="taskNodeType != null  and taskNodeType != ''"> and task_node_type = #{taskNodeType}</if>
            <if test="taskNodeBefore != null  and taskNodeBefore != ''"> and task_node_before = #{taskNodeBefore}</if>
            <if test="taskNodeAfter != null  and taskNodeAfter != ''"> and task_node_after = #{taskNodeAfter}</if>
            <if test="taskNodeRolePermission != null  and taskNodeRolePermission != ''"> and task_node_role_permission = #{taskNodeRolePermission}</if>
            <if test="taskRemark != null  and taskRemark != ''"> and task_remark = #{taskRemark}</if>
            <if test="taskNodeNumber != null  and taskNodeNumber != ''"> and task_node_number = #{taskNodeNumber}</if>
            <if test="taskNodeWeight != null  and taskNodeWeight != ''"> and task_node_weight = #{taskNodeWeight}</if>
            <if test="taskNodeState != null  and taskNodeState != ''"> and task_node_state = #{taskNodeState}</if>
            <if test="taskPriority != null  and taskPriority != ''"> and task_priority = #{taskPriority}</if>
            <if test="task1 != null  and task1 != ''"> and task1 = #{task1}</if>
            <if test="task2 != null  and task2 != ''"> and task2 = #{task2}</if>
            <if test="task3 != null  and task3 != ''"> and task3 = #{task3}</if>
            <if test="task4 != null  and task4 != ''"> and task4 = #{task4}</if>
            <if test="task5 != null  and task5 != ''"> and task5 = #{task5}</if>
<!--&#45;&#45;             <if test="createById != null  and createById != ''"> and create_by_id = #{createById}</if>-->
        </where>
    </select>
    
    <select id="selectBpmExecuteNodeById" parameterType="Long" resultMap="BpmExecuteNodeResult">
        <include refid="selectBpmExecuteNodeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBpmExecuteNode" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNode" useGeneratedKeys="true" keyProperty="id">
        insert into bpm_execute_node
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskProcessKey != null">task_process_key,</if>
            <if test="taskNodeKey != null">task_node_key,</if>
            <if test="taskNodeName != null">task_node_name,</if>
            <if test="taskNodeFormKey != null">task_node_form_key,</if>
            <if test="taskNodeType != null">task_node_type,</if>
            <if test="taskNodeBefore != null">task_node_before,</if>
            <if test="taskNodeAfter != null">task_node_after,</if>
            <if test="taskNodeRolePermission != null">task_node_role_permission,</if>
            <if test="taskRemark != null">task_remark,</if>
            <if test="taskNodeNumber != null">task_node_number,</if>
            <if test="taskNodeWeight != null">task_node_weight,</if>
            <if test="taskNodeState != null">task_node_state,</if>
            <if test="taskPriority != null">task_priority,</if>
            <if test="task1 != null">task1,</if>
            <if test="task2 != null">task2,</if>
            <if test="task3 != null">task3,</if>
            <if test="task4 != null">task4,</if>
            <if test="task5 != null">task5,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createById != null">create_by_id,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskProcessKey != null">#{taskProcessKey},</if>
            <if test="taskNodeKey != null">#{taskNodeKey},</if>
            <if test="taskNodeName != null">#{taskNodeName},</if>
            <if test="taskNodeFormKey != null">#{taskNodeFormKey},</if>
            <if test="taskNodeType != null">#{taskNodeType},</if>
            <if test="taskNodeBefore != null">#{taskNodeBefore},</if>
            <if test="taskNodeAfter != null">#{taskNodeAfter},</if>
            <if test="taskNodeRolePermission != null">#{taskNodeRolePermission},</if>
            <if test="taskRemark != null">#{taskRemark},</if>
            <if test="taskNodeNumber != null">#{taskNodeNumber},</if>
            <if test="taskNodeWeight != null">#{taskNodeWeight},</if>
            <if test="taskNodeState != null">#{taskNodeState},</if>
            <if test="taskPriority != null">#{taskPriority},</if>
            <if test="task1 != null">#{task1},</if>
            <if test="task2 != null">#{task2},</if>
            <if test="task3 != null">#{task3},</if>
            <if test="task4 != null">#{task4},</if>
            <if test="task5 != null">#{task5},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createById != null">#{createById},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <insert id="insertBpmExecuteNodeList" parameterType="java.util.List">
        insert into bpm_execute_node (
        task_process_key,
        task_node_key,
        task_node_name,
        task_node_form_key,
        task_node_type,
        task_node_before,
        task_node_after,
        task_node_role_permission,
        task_remark,
        task_node_number,
        task_node_weight,
        task_node_state,
        task_priority,
        task1,
        task2,
        task3,
        task4,
        task5,
        del_flag,
        create_by_id,
        create_by,
        create_time )values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.taskProcessKey},
            #{item.taskNodeKey},
            #{item.taskNodeName},
            #{item.taskNodeFormKey},
            #{item.taskNodeType},
            #{item.taskNodeBefore},
            #{item.taskNodeAfter},
            #{item.taskNodeRolePermission},
            #{item.taskRemark},
            #{item.taskNodeNumber},
            #{item.taskNodeWeight},
            #{item.taskNodeState},
            #{item.taskPriority},
            #{item.task1},
            #{item.task2},
            #{item.task3},
            #{item.task4},
            #{item.task5},
            #{item.delFlag},
            #{item.createById},
            #{item.createBy},
            #{item.createTime})
        </foreach>
    </insert>

    <update id="updateBpmExecuteNode" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNode">
        update bpm_execute_node
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskProcessKey != null">task_process_key = #{taskProcessKey},</if>
            <if test="taskNodeKey != null">task_node_key = #{taskNodeKey},</if>
            <if test="taskNodeName != null">task_node_name = #{taskNodeName},</if>
            <if test="taskNodeFormKey != null">task_node_form_key = #{taskNodeFormKey},</if>
            <if test="taskNodeType != null">task_node_type = #{taskNodeType},</if>
            <if test="taskNodeBefore != null">task_node_before = #{taskNodeBefore},</if>
            <if test="taskNodeAfter != null">task_node_after = #{taskNodeAfter},</if>
            <if test="taskNodeRolePermission != null">task_node_role_permission = #{taskNodeRolePermission},</if>
            <if test="taskRemark != null">task_remark = #{taskRemark},</if>
            <if test="taskNodeNumber != null">task_node_number = #{taskNodeNumber},</if>
            <if test="taskNodeWeight != null">task_node_weight = #{taskNodeWeight},</if>
            <if test="taskNodeState != null">task_node_state = #{taskNodeState},</if>
            <if test="taskPriority != null">task_priority = #{taskPriority},</if>
            <if test="task1 != null">task1 = #{task1},</if>
            <if test="task2 != null">task2 = #{task2},</if>
            <if test="task3 != null">task3 = #{task3},</if>
            <if test="task4 != null">task4 = #{task4},</if>
            <if test="task5 != null">task5 = #{task5},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createById != null">create_by_id = #{createById},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBpmExecuteNodeById" parameterType="Long">
        delete from bpm_execute_node where id = #{id}
    </delete>

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