<?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.SearchContentMapper">
    
    <resultMap type="SearchContent" id="SearchContentResult">
        <result property="id"    column="id"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectSearchContentVo">
        select id, content, create_time from search_content
    </sql>

    <select id="selectSearchContentList" parameterType="SearchContent" resultMap="SearchContentResult">
        <include refid="selectSearchContentVo"/>
        <where>  
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectSearchContentById" parameterType="String" resultMap="SearchContentResult">
        <include refid="selectSearchContentVo"/>
        where id = #{id}
    </select>

    <insert id="insertSearchContent" parameterType="SearchContent" useGeneratedKeys="true" keyProperty="id">
        insert into search_content
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="content != null">content,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="content != null">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateSearchContent" parameterType="SearchContent">
        update search_content
        <trim prefix="SET" suffixOverrides=",">
            <if test="content != null">content = #{content},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSearchContentById" parameterType="String">
        delete from search_content where id = #{id}
    </delete>

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