<?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.solution.system.mapper.NodeparameterMapper">
    
    <resultMap type="Nodeparameter" id="NodeparameterResult">
        <result property="id"    column="id"    />
        <result property="nodeInstanceId"    column="node_instance_id"    />
        <result property="paramDefId"    column="param_def_id"    />
        <result property="value"    column="value"    />
    </resultMap>

    <sql id="selectNodeparameterVo">
        select id, node_instance_id, param_def_id, value from nodeparameter
    </sql>

    <select id="selectNodeparameterList" parameterType="Nodeparameter" resultMap="NodeparameterResult">
        <include refid="selectNodeparameterVo"/>
        <where>  
            <if test="nodeInstanceId != null "> and node_instance_id = #{nodeInstanceId}</if>
            <if test="paramDefId != null "> and param_def_id = #{paramDefId}</if>
            <if test="value != null  and value != ''"> and value = #{value}</if>
        </where>
    </select>
    
    <select id="selectNodeparameterById" parameterType="Long" resultMap="NodeparameterResult">
        <include refid="selectNodeparameterVo"/>
        where id = #{id}
    </select>

    <insert id="insertNodeparameter" parameterType="Nodeparameter" useGeneratedKeys="true" keyProperty="id">
        insert into nodeparameter
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nodeInstanceId != null">node_instance_id,</if>
            <if test="paramDefId != null">param_def_id,</if>
            <if test="value != null">value,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="nodeInstanceId != null">#{nodeInstanceId},</if>
            <if test="paramDefId != null">#{paramDefId},</if>
            <if test="value != null">#{value},</if>
         </trim>
    </insert>

    <update id="updateNodeparameter" parameterType="Nodeparameter">
        update nodeparameter
        <trim prefix="SET" suffixOverrides=",">
            <if test="nodeInstanceId != null">node_instance_id = #{nodeInstanceId},</if>
            <if test="paramDefId != null">param_def_id = #{paramDefId},</if>
            <if test="value != null">value = #{value},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteNodeparameterById" parameterType="Long">
        delete from nodeparameter where id = #{id}
    </delete>

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