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

    <resultMap type="FastgptTagGroup" id="FastgptTagGroupResult">
        <result property="id"    column="id"    />
        <result property="tag"    column="tag"    />
        <result property="sort"    column="sort"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectFastgptTagGroupVo">
        select id, tag, sort, create_time, update_time from fastgpt_tag_group
    </sql>

    <select id="selectFastgptTagGroupList" parameterType="FastgptTagGroup" resultMap="FastgptTagGroupResult">
        <include refid="selectFastgptTagGroupVo"/>
        <where>
            <if test="tag != null  and tag != ''"> and tag = #{tag}</if>
            <if test="sort != null "> and sort = #{sort}</if>
        </where>
    </select>

    <select id="selectFastgptTagGroupById" parameterType="Long" resultMap="FastgptTagGroupResult">
        <include refid="selectFastgptTagGroupVo"/>
        where id = #{id}
    </select>

    <insert id="insertFastgptTagGroup" parameterType="FastgptTagGroup" useGeneratedKeys="true" keyProperty="id">
        insert into fastgpt_tag_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tag != null">tag,</if>
            <if test="sort != null">sort,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tag != null">#{tag},</if>
            <if test="sort != null">#{sort},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateFastgptTagGroup" parameterType="FastgptTagGroup">
        update fastgpt_tag_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="tag != null">tag = #{tag},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFastgptTagGroupById" parameterType="Long">
        delete from fastgpt_tag_group where id = #{id}
    </delete>

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