<?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.NodetemplateMapper">
    
    <resultMap type="Nodetemplate" id="NodetemplateResult">
        <result property="id"    column="id"    />
        <result property="type"    column="type"    />
        <result property="name"    column="name"    />
        <result property="logicHandler"    column="logic_handler"    />
        <result property="description"    column="description"    />
        <result property="englishName"    column="english_name"    />
        <result property="templeteType"    column="templete_type"    />
    </resultMap>

    <sql id="selectNodetemplateVo">
        select id, type, name, logic_handler, description, english_name, templete_type from nodetemplate
    </sql>

    <select id="selectNodetemplateList" parameterType="Nodetemplate" resultMap="NodetemplateResult">
        <include refid="selectNodetemplateVo"/>
        <where>  
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="logicHandler != null  and logicHandler != ''"> and logic_handler = #{logicHandler}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="englishName != null  and englishName != ''"> and english_name like concat('%', #{englishName}, '%')</if>
            <if test="templeteType != null  and templeteType != ''"> and templete_type = #{templeteType}</if>
        </where>
    </select>
    
    <select id="selectNodetemplateById" parameterType="Long" resultMap="NodetemplateResult">
        <include refid="selectNodetemplateVo"/>
        where id = #{id}
    </select>

    <insert id="insertNodetemplate" parameterType="Nodetemplate" useGeneratedKeys="true" keyProperty="id">
        insert into nodetemplate
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null and type != ''">type,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="logicHandler != null">logic_handler,</if>
            <if test="description != null">description,</if>
            <if test="englishName != null">english_name,</if>
            <if test="templeteType != null and templeteType != ''">templete_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null and type != ''">#{type},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="logicHandler != null">#{logicHandler},</if>
            <if test="description != null">#{description},</if>
            <if test="englishName != null">#{englishName},</if>
            <if test="templeteType != null and templeteType != ''">#{templeteType},</if>
         </trim>
    </insert>

    <update id="updateNodetemplate" parameterType="Nodetemplate">
        update nodetemplate
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null and type != ''">type = #{type},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="logicHandler != null">logic_handler = #{logicHandler},</if>
            <if test="description != null">description = #{description},</if>
            <if test="englishName != null">english_name = #{englishName},</if>
            <if test="templeteType != null and templeteType != ''">templete_type = #{templeteType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteNodetemplateById" parameterType="Long">
        delete from nodetemplate where id = #{id}
    </delete>

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