<?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.ai.mapper.AiHelpMapper">
    
    <resultMap type="AiHelp" id="AiHelpResult">
        <result property="id"    column="id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectAiHelpVo">
        select id, del_flag, create_by, create_time, update_by, update_time, remark, title, content, status from ai_help
    </sql>

    <select id="selectAiHelpList" parameterType="AiHelp" resultMap="AiHelpResult">
        <include refid="selectAiHelpVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="status != null "> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectAiHelpById" parameterType="Long" resultMap="AiHelpResult">
        <include refid="selectAiHelpVo"/>
        where id = #{id}
    </select>

    <insert id="insertAiHelp" parameterType="AiHelp" useGeneratedKeys="true" keyProperty="id">
        insert into ai_help
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="delFlag != null and delFlag != ''">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="delFlag != null and delFlag != ''">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="status != null">#{status},</if>
         </trim>
    </insert>

    <update id="updateAiHelp" parameterType="AiHelp">
        update ai_help
        <trim prefix="SET" suffixOverrides=",">
            <if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAiHelpById" parameterType="Long">
        delete from ai_help where id = #{id}
    </delete>

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