<?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.FastgptTagMapper">

    <resultMap type="FastgptTag" id="FastgptTagResult">
        <result property="id"    column="id"    />
        <result property="tagGroupId"    column="tag_group_id"    />
        <result property="tag"    column="tag"    />
        <result property="keyword"    column="keyword"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFastgptTagVo">
        select id, tag_group_id, tag, keyword, create_by, update_by, create_time, update_time from fastgpt_tag
    </sql>

    <select id="selectFastgptTagList" parameterType="FastgptTag" resultMap="FastgptTagResult">
        <include refid="selectFastgptTagVo"/>
        <where>
            <if test="tagGroupId != null "> and tag_group_id = #{tagGroupId}</if>
            <if test="tag != null  and tag != ''"> and tag = #{tag}</if>
            <if test="keyword != null  and keyword != ''"> and keyword = #{keyword}</if>
        </where>
    </select>

    <select id="selectFastgptTagById" parameterType="Long" resultMap="FastgptTagResult">
        <include refid="selectFastgptTagVo"/>
        where id = #{id}
    </select>

    <insert id="insertFastgptTag" parameterType="FastgptTag" useGeneratedKeys="true" keyProperty="id">
        insert into fastgpt_tag
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tagGroupId != null">tag_group_id,</if>
            <if test="tag != null">tag,</if>
            <if test="keyword != null">keyword,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tagGroupId != null">#{tagGroupId},</if>
            <if test="tag != null">#{tag},</if>
            <if test="keyword != null">#{keyword},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateFastgptTag" parameterType="FastgptTag">
        update fastgpt_tag
        <trim prefix="SET" suffixOverrides=",">
            <if test="tagGroupId != null">tag_group_id = #{tagGroupId},</if>
            <if test="tag != null">tag = #{tag},</if>
            <if test="keyword != null">keyword = #{keyword},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFastgptTagById" parameterType="Long">
        delete from fastgpt_tag where id = #{id}
    </delete>

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