<?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.AiManagerMapper">
    
    <resultMap type="AiManager" id="AiManagerResult">
        <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="price"    column="price"    />
        <result property="status"    column="status"    />
        <result property="prompt"    column="prompt"    />
        <result property="type"    column="type"    />
        <result property="text"    column="text"    />
    </resultMap>

    <sql id="selectAiManagerVo">
        select id, del_flag, create_by, create_time, update_by, update_time, remark, title, price, status, prompt, type, text from ai_manager
    </sql>

    <select id="selectAiManagerList" parameterType="AiManager" resultMap="AiManagerResult">
        <include refid="selectAiManagerVo"/>
        <where>
            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="text != null "> and text = #{text}</if>
        </where>
    </select>
    
    <select id="selectAiManagerById" parameterType="Long" resultMap="AiManagerResult">
        <include refid="selectAiManagerVo"/>
        where id = #{id}
    </select>

    <insert id="insertAiManager" parameterType="AiManager" useGeneratedKeys="true" keyProperty="id">
        insert into ai_manager
        <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="price != null">price,</if>
            <if test="status != null">status,</if>
            <if test="prompt != null">prompt,</if>
            <if test="type != null">type,</if>
            <if test="text != null">text,</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="price != null">#{price},</if>
            <if test="status != null">#{status},</if>
            <if test="prompt != null">#{prompt},</if>
            <if test="type != null">#{type},</if>
            <if test="text != null">#{text},</if>
         </trim>
    </insert>

    <update id="updateAiManager" parameterType="AiManager">
        update ai_manager
        <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="price != null">price = #{price},</if>
            <if test="status != null">status = #{status},</if>
            <if test="type != null">type = #{type},</if>
            <if test="text != null">text = #{text},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAiManagerById" parameterType="Long">
        delete from ai_manager where id = #{id}
    </delete>

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