<?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.TemplateTableMapper">
    
    <resultMap type="TemplateTable" id="TemplateTableResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="url"    column="url"    />
    </resultMap>

    <sql id="selectTemplateTableVo">
        select id, name, url from template_table
    </sql>

    <select id="selectTemplateTableList" parameterType="TemplateTable" resultMap="TemplateTableResult">
        <include refid="selectTemplateTableVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
        </where>
    </select>
    
    <select id="selectTemplateTableById" parameterType="Long" resultMap="TemplateTableResult">
        <include refid="selectTemplateTableVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTemplateTable" parameterType="TemplateTable">
        insert into template_table
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="name != null">name,</if>
            <if test="url != null">url,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="name != null">#{name},</if>
            <if test="url != null">#{url},</if>
         </trim>
    </insert>

    <update id="updateTemplateTable" parameterType="TemplateTable">
        update template_table
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null">name = #{name},</if>
            <if test="url != null">url = #{url},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTemplateTableById" parameterType="Long">
        delete from template_table where id = #{id}
    </delete>

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