<?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.sy.mapper.SyKnowledgeInterstTypeMapper">
    
    <resultMap type="SyKnowledgeInterstType" id="SyKnowledgeInterstTypeResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="key"    column="key"    />
        <result property="name"    column="name"    />
        <result property="content"    column="content"    />
    </resultMap>

    <sql id="selectSyKnowledgeInterstTypeVo">
        select id, code, `key`, name, content from sy_knowledge_interst_type
    </sql>

    <select id="selectSyKnowledgeInterstTypeList" parameterType="SyKnowledgeInterstType" resultMap="SyKnowledgeInterstTypeResult">
        <include refid="selectSyKnowledgeInterstTypeVo"/>
        <where>  
            <if test="code != null  and code != ''"> and code = #{code}</if>
            <if test="key != null  and key != ''"> and `key` = #{key}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
        </where>
    </select>
    
    <select id="selectSyKnowledgeInterstTypeById" parameterType="Long" resultMap="SyKnowledgeInterstTypeResult">
        <include refid="selectSyKnowledgeInterstTypeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSyKnowledgeInterstType" parameterType="SyKnowledgeInterstType" useGeneratedKeys="true" keyProperty="id">
        insert into sy_knowledge_interst_type
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="code != null">code,</if>
            <if test="key != null">`key`,</if>
            <if test="name != null">name,</if>
            <if test="content != null">content,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="code != null">#{code},</if>
            <if test="key != null">#{key},</if>
            <if test="name != null">#{name},</if>
            <if test="content != null">#{content},</if>
         </trim>
    </insert>

    <update id="updateSyKnowledgeInterstType" parameterType="SyKnowledgeInterstType">
        update sy_knowledge_interst_type
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="key != null">`key` = #{key},</if>
            <if test="name != null">name = #{name},</if>
            <if test="content != null">content = #{content},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSyKnowledgeInterstTypeById" parameterType="Long">
        delete from sy_knowledge_interst_type where id = #{id}
    </delete>

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