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

    <resultMap type="com.ruoyi.system.entity.BpmNodeScriptRelevance" id="BpmNodeScriptRelevanceResult">
        <result property="id" column="id"/>
        <result property="nodeKey" column="node_key"/>
        <result property="scriptKey" column="script_key"/>
        <result property="scriptTriggerType" column="script_trigger_type"/>
    </resultMap>

    <sql id="selectBpmNodeScriptRelevanceVo">
        select id, node_key, script_key, script_trigger_type
        from bpm_node_script_relevance
    </sql>

    <select id="selectBpmNodeScriptRelevanceList" parameterType="com.ruoyi.system.entity.BpmNodeScriptRelevance"
            resultMap="BpmNodeScriptRelevanceResult">
        <include refid="selectBpmNodeScriptRelevanceVo"/>
        <where>
            <if test="nodeKey != null  and nodeKey != ''">and node_key = #{nodeKey}</if>
            <if test="scriptKey != null  and scriptKey != ''">and script_key = #{scriptKey}</if>
            <if test="scriptTriggerType != null ">and script_trigger_type = #{scriptTriggerType}</if>
        </where>
    </select>

    <select id="selectBpmNodeScriptRelevanceById" parameterType="Long" resultMap="BpmNodeScriptRelevanceResult">
        <include refid="selectBpmNodeScriptRelevanceVo"/>
        where id = #{id}
    </select>

    <insert id="insertBpmNodeScriptRelevance" parameterType="java.util.List">
        insert into bpm_node_script_relevance( node_key,script_key,script_trigger_type )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.nodeKey},#{item.scriptKey},#{item.scriptTriggerType})
        </foreach>
    </insert>
<!--    <foreach collection="list" item="item" index="index" separator=";">-->
    <update id="updateBpmNodeScriptRelevance" parameterType="com.ruoyi.system.entity.BpmNodeScriptRelevance">

        update bpm_node_script_relevance
        <trim prefix="SET" suffixOverrides=",">
            <if test="nodeKey != null">node_key = #{nodeKey},</if>
            <if test="scriptKey != null">script_key = #{scriptKey},</if>
            <if test="scriptTriggerType != null">script_trigger_type = #{scriptTriggerType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBpmNodeScriptRelevanceById" parameterType="Long">
        update bpm_node_script_relevance
        set del_flag = '2'
        where id = #{id}
    </delete>

    <delete id="deleteBpmNodeScriptRelevanceByIds" parameterType="String">
        update bpm_node_script_relevance set del_flag = '2' where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>