<?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.TSettingMapper">
    
    <resultMap type="TSetting" id="TSettingResult">
        <result property="id"    column="id"    />
        <result property="useKey"    column="use_key"    />
        <result property="useValue"    column="use_value"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectTSettingVo">
        select id, use_key, use_value, remark from t_setting
    </sql>

    <select id="selectTSettingList" parameterType="TSetting" resultMap="TSettingResult">
        SELECT use_key,use_value FROM `t_setting`
        where use_key in
              ("shouhuan_heart_max",
               "shouhuan_heart_min",
               "shouhuan_blood_high_max",
               "shouhuan_blood_high_min",
               "shouhuan_blood_low_max",
               "shouhuan_blood_low_min",
               "shouhuan_oxygen_max",
               "shouhuan_oxygen_min",
               "shouhuan_body_max",
               "shouhuan_body_min")
    </select>
    
    <select id="selectTSettingById" parameterType="Integer" resultMap="TSettingResult">
        <include refid="selectTSettingVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTSetting" parameterType="TSetting" useGeneratedKeys="true" keyProperty="id">
        insert into t_setting
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="useKey != null">use_key,</if>
            <if test="useValue != null">use_value,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="useKey != null">#{useKey},</if>
            <if test="useValue != null">#{useValue},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateTSetting" parameterType="TSetting">
        update t_setting
        <trim prefix="SET" suffixOverrides=",">
            <if test="useKey != null">use_key = #{useKey},</if>
            <if test="useValue != null">use_value = #{useValue},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTSettingById" parameterType="Integer">
        delete from t_setting where id = #{id}
    </delete>

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