<?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.system.mapper.ButlerSettingsMapper">
    
    <resultMap type="ButlerSettings" id="ButlerSettingsResult">
        <result property="settingsId"    column="settings_id"    />
        <result property="title"    column="title"    />
        <result property="content"    column="content"    />
        <result property="isDel"    column="is_del"    />
        <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"    />
    </resultMap>

    <sql id="selectButlerSettingsVo">
        select settings_id, title, content, is_del, create_by, create_time, update_by, update_time, remark from butler_settings
    </sql>

    <select id="selectButlerSettingsList" parameterType="ButlerSettings" resultMap="ButlerSettingsResult">
        <include refid="selectButlerSettingsVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="isDel != null  and isDel != ''"> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectButlerSettingsBySettingsId" parameterType="Long" resultMap="ButlerSettingsResult">
        <include refid="selectButlerSettingsVo"/>
        where settings_id = #{settingsId}
    </select>

    <insert id="insertButlerSettings" parameterType="ButlerSettings" useGeneratedKeys="true" keyProperty="settingsId">
        insert into butler_settings
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="content != null">content,</if>
            <if test="isDel != null">is_del,</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>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="content != null">#{content},</if>
            <if test="isDel != null">#{isDel},</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>
         </trim>
    </insert>

    <update id="updateButlerSettings" parameterType="ButlerSettings">
        update butler_settings
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="content != null">content = #{content},</if>
            <if test="isDel != null">is_del = #{isDel},</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>
        </trim>
        where settings_id = #{settingsId}
    </update>

    <delete id="deleteButlerSettingsBySettingsId" parameterType="Long">
        delete from butler_settings where settings_id = #{settingsId}
    </delete>

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