<?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.base.mapper.RobotOpsFaqSimilarMapper">
    
    <resultMap type="RobotOpsFaqSimilar" id="RobotOpsFaqSimilarResult">
        <result property="id"    column="id"    />
        <result property="faqId"    column="faq_id"    />
        <result property="similarQuestion"    column="similar_question"    />
        <result property="sortNo"    column="sort_no"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectRobotOpsFaqSimilarVo">
        select id, faq_id, similar_question, sort_no, create_by, update_by from robot_ops_faq_similar
    </sql>

    <select id="selectRobotOpsFaqSimilarList" parameterType="RobotOpsFaqSimilar" resultMap="RobotOpsFaqSimilarResult">
        <include refid="selectRobotOpsFaqSimilarVo"/>
        <where>  
            <if test="faqId != null "> and faq_id = #{faqId}</if>
            <if test="similarQuestion != null  and similarQuestion != ''"> and similar_question = #{similarQuestion}</if>
            <if test="sortNo != null "> and sort_no = #{sortNo}</if>
        </where>
    </select>
    
    <select id="selectRobotOpsFaqSimilarById" parameterType="Long" resultMap="RobotOpsFaqSimilarResult">
        <include refid="selectRobotOpsFaqSimilarVo"/>
        where id = #{id}
    </select>

    <insert id="insertRobotOpsFaqSimilar" parameterType="RobotOpsFaqSimilar" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_faq_similar
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="faqId != null">faq_id,</if>
            <if test="similarQuestion != null and similarQuestion != ''">similar_question,</if>
            <if test="sortNo != null">sort_no,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="faqId != null">#{faqId},</if>
            <if test="similarQuestion != null and similarQuestion != ''">#{similarQuestion},</if>
            <if test="sortNo != null">#{sortNo},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
         </trim>
    </insert>

    <update id="updateRobotOpsFaqSimilar" parameterType="RobotOpsFaqSimilar">
        update robot_ops_faq_similar
        <trim prefix="SET" suffixOverrides=",">
            <if test="faqId != null">faq_id = #{faqId},</if>
            <if test="similarQuestion != null and similarQuestion != ''">similar_question = #{similarQuestion},</if>
            <if test="sortNo != null">sort_no = #{sortNo},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRobotOpsFaqSimilarById" parameterType="Long">
        delete from robot_ops_faq_similar where id = #{id}
    </delete>

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