<?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.BpmExecuteNodeMiddleMapper">
    
    <resultMap type="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNodeMiddle" id="BpmExecuteNodeMiddleResult">
        <result property="id"    column="id"    />
        <result property="taskNodeKey"    column="task_node_key"    />
        <result property="taskVirtuallyRole"    column="task_virtually_role"    />
        <result property="taskRealRole"    column="task_real_role"    />
        <result property="taskExecuteUserNo"    column="task_execute_user_no"    />
        <result property="taskArtificialScriptKey"    column="task_artificial_script_key"    />
        <result property="taskAutomaticScriptTriggerType"    column="task_automatic_script_trigger_type"    />
    </resultMap>

    <sql id="selectBpmExecuteNodeMiddleVo">
        select id, task_node_key, task_virtually_role, task_real_role, task_execute_user_no, task_artificial_script_key, task_automatic_script_trigger_type from bpm_execute_node_middle
    </sql>

    <select id="selectBpmExecuteNodeMiddleList" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNodeMiddle" resultMap="BpmExecuteNodeMiddleResult">
        <include refid="selectBpmExecuteNodeMiddleVo"/>
        <where>  
            <if test="taskNodeKey != null  and taskNodeKey != ''"> and task_node_key = #{taskNodeKey}</if>
            <if test="taskVirtuallyRole != null  and taskVirtuallyRole != ''"> and task_virtually_role = #{taskVirtuallyRole}</if>
            <if test="taskRealRole != null  and taskRealRole != ''"> and task_real_role = #{taskRealRole}</if>
            <if test="taskExecuteUserNo != null  and taskExecuteUserNo != ''"> and task_execute_user_no = #{taskExecuteUserNo}</if>
            <if test="taskArtificialScriptKey != null  and taskArtificialScriptKey != ''"> and task_artificial_script_key = #{taskArtificialScriptKey}</if>
            <if test="taskAutomaticScriptTriggerType != null  and taskAutomaticScriptTriggerType != ''"> and task_automatic_script_trigger_type = #{taskAutomaticScriptTriggerType}</if>
        </where>
    </select>
    
    <select id="selectBpmExecuteNodeMiddleById" parameterType="Long" resultMap="BpmExecuteNodeMiddleResult">
        <include refid="selectBpmExecuteNodeMiddleVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertBpmExecuteNodeMiddle" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNodeMiddle" useGeneratedKeys="true" keyProperty="id">
        insert into bpm_execute_node_middle
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="taskNodeKey != null">task_node_key,</if>
            <if test="taskVirtuallyRole != null">task_virtually_role,</if>
            <if test="taskRealRole != null">task_real_role,</if>
            <if test="taskExecuteUserNo != null">task_execute_user_no,</if>
            <if test="taskArtificialScriptKey != null">task_artificial_script_key,</if>
            <if test="taskAutomaticScriptTriggerType != null">task_automatic_script_trigger_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskNodeKey != null">#{taskNodeKey},</if>
            <if test="taskVirtuallyRole != null">#{taskVirtuallyRole},</if>
            <if test="taskRealRole != null">#{taskRealRole},</if>
            <if test="taskExecuteUserNo != null">#{taskExecuteUserNo},</if>
            <if test="taskArtificialScriptKey != null">#{taskArtificialScriptKey},</if>
            <if test="taskAutomaticScriptTriggerType != null">#{taskAutomaticScriptTriggerType},</if>
         </trim>
    </insert>
   <insert id="insertBpmExecuteNodeMiddleList" parameterType="java.util.List">
       insert into bpm_execute_node_middle(task_node_key,
       task_virtually_role,
       task_real_role,
       task_execute_user_no,
       task_artificial_script_key,
       task_automatic_script_trigger_type)
       values
       <foreach collection="list" item="item" index="index" separator=",">
           (#{item.taskNodeKey},
           #{item.taskVirtuallyRole},
           #{item.taskRealRole},
           #{item.taskExecuteUserNo},
           #{item.taskArtificialScriptKey},
           #{item.taskAutomaticScriptTriggerType})
       </foreach>
   </insert>

    <update id="updateBpmExecuteNodeMiddle" parameterType="com.ruoyi.execution.produce.dispersed.enetity.BpmExecuteNodeMiddle">
        update bpm_execute_node_middle
        <trim prefix="SET" suffixOverrides=",">
            <if test="taskNodeKey != null">task_node_key = #{taskNodeKey},</if>
            <if test="taskVirtuallyRole != null">task_virtually_role = #{taskVirtuallyRole},</if>
            <if test="taskRealRole != null">task_real_role = #{taskRealRole},</if>
            <if test="taskExecuteUserNo != null">task_execute_user_no = #{taskExecuteUserNo},</if>
            <if test="taskArtificialScriptKey != null">task_artificial_script_key = #{taskArtificialScriptKey},</if>
            <if test="taskAutomaticScriptTriggerType != null">task_automatic_script_trigger_type = #{taskAutomaticScriptTriggerType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBpmExecuteNodeMiddleById" parameterType="Long">
        delete from bpm_execute_node_middle where id = #{id}
    </delete>

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