<?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.fs.fastGpt.mapper.FastGptRoleTagMapper">

    <resultMap type="FastGptRoleTag" id="FastGptRoleTagResult">
        <result property="id"    column="id"    />
        <result property="roleId"    column="role_id"    />
        <result property="tagIds"    column="tag_ids"    />
        <result property="reminderWords"    column="reminder_words"    />
    </resultMap>

    <sql id="selectFastGptRoleTagVo">
        select id, role_id, tag_ids, reminder_words from fastgpt_role_tag
    </sql>

    <select id="selectFastGptRoleTagList" parameterType="FastGptRoleTag" resultMap="FastGptRoleTagResult">
        <include refid="selectFastGptRoleTagVo"/>
        <where>
            <if test="roleId != null "> and role_id = #{roleId}</if>
            <if test="tagIds != null  and tagIds != ''"> and tag_ids = #{tagIds}</if>
            <if test="reminderWords != null  and reminderWords != ''"> and reminder_words = #{reminderWords}</if>
        </where>
    </select>

    <select id="selectFastGptRoleTagById" parameterType="Long" resultMap="FastGptRoleTagResult">
        <include refid="selectFastGptRoleTagVo"/>
        where id = #{id}
    </select>

    <insert id="insertFastGptRoleTag" parameterType="FastGptRoleTag">
        insert into fastgpt_role_tag
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="roleId != null">role_id,</if>
            <if test="tagIds != null">tag_ids,</if>
            <if test="reminderWords != null">reminder_words,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="roleId != null">#{roleId},</if>
            <if test="tagIds != null">#{tagIds},</if>
            <if test="reminderWords != null">#{reminderWords},</if>
         </trim>
    </insert>

    <update id="updateFastGptRoleTag" parameterType="FastGptRoleTag">
        update fastgpt_role_tag
        <trim prefix="SET" suffixOverrides=",">
            <if test="roleId != null">role_id = #{roleId},</if>
            <if test="tagIds != null">tag_ids = #{tagIds},</if>
            <if test="reminderWords != null">reminder_words = #{reminderWords},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFastGptRoleTagById" parameterType="Long">
        delete from fastgpt_role_tag where id = #{id}
    </delete>

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