<?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.sckw.slope.detection.dao.mysql.KwsThresholdMapper">
    <resultMap id="BaseResultMap" type="com.sckw.slope.detection.model.dos.mysql.KwsThreshold">
        <!--@mbg.generated-->
        <!--@Table kws_threshold-->
        <id column="id" jdbcType="BIGINT" property="id"/>
        <result column="device_id" jdbcType="BIGINT" property="deviceId"/>
        <result column="item_name" jdbcType="VARCHAR" property="itemName"/>
        <result column="level" jdbcType="INTEGER" property="level"/>
        <result column="mountain_id" jdbcType="VARCHAR" property="mountainId"/>
        <result column="setting" jdbcType="VARCHAR" property="setting"/>
        <result column="max" jdbcType="VARCHAR" property="max"/>
        <result column="min" jdbcType="VARCHAR" property="min"/>
        <result column="phones" jdbcType="VARCHAR" property="phones"/>
        <result column="status" jdbcType="TINYINT" property="status"/>
        <result column="create_by" jdbcType="BIGINT" property="createBy"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_by" jdbcType="BIGINT" property="updateBy"/>
        <result column="create_name" jdbcType="VARCHAR" property="createName"/>
        <result column="update_name" jdbcType="VARCHAR" property="updateName"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
        <result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id,
        device_id,
        setting,
        mountain_id,
        update_name,
        create_name,
        item_name,
        `level`,
        `max`,
        `min`,
        phones,
        `status`,
        create_by,
        update_name,
        create_time,
        update_by,
        update_time,
        del_flag
    </sql>
    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
        <!--@mbg.generated-->
        select
        <include refid="Base_Column_List"/>
        from kws_threshold
        where id = #{id,jdbcType=BIGINT}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
        <!--@mbg.generated-->
        delete
        from kws_threshold
        where id = #{id,jdbcType=BIGINT}
    </delete>
    <insert id="insertSelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsThreshold">
        <!--@mbg.generated-->
        insert into kws_threshold
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="deviceId != null">
                device_id,
            </if>
            <if test="itemName != null">
                item_name,
            </if>
            <if test="level != null">
                `level`,
            </if>
            <if test="max != null">
                `max`,
            </if>
            <if test="min != null">
                `min`,
            </if>
            <if test="phones != null">
                phones,
            </if>
            <if test="status != null">
                `status`,
            </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="delFlag != null">
                del_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="deviceId != null">
                #{deviceId,jdbcType=BIGINT},
            </if>
            <if test="itemName != null">
                #{itemName,jdbcType=VARCHAR},
            </if>
            <if test="level != null">
                #{level,jdbcType=INTEGER},
            </if>
            <if test="max != null">
                #{max,jdbcType=VARCHAR},
            </if>
            <if test="min != null">
                #{min,jdbcType=VARCHAR},
            </if>
            <if test="phones != null">
                #{phones,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                #{status,jdbcType=TINYINT},
            </if>
            <if test="createBy != null">
                #{createBy,jdbcType=BIGINT},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                #{updateBy,jdbcType=BIGINT},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="delFlag != null">
                #{delFlag,jdbcType=TINYINT},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsThreshold">
        <!--@mbg.generated-->
        update kws_threshold
        <set>
            <if test="deviceId != null">
                device_id = #{deviceId,jdbcType=BIGINT},
            </if>
            <if test="itemName != null">
                item_name = #{itemName,jdbcType=VARCHAR},
            </if>
            <if test="level != null">
                `level` = #{level,jdbcType=INTEGER},
            </if>
            <if test="max != null">
                `max` = #{max,jdbcType=VARCHAR},
            </if>
            <if test="min != null">
                `min` = #{min,jdbcType=VARCHAR},
            </if>
            <if test="phones != null">
                phones = #{phones,jdbcType=VARCHAR},
            </if>
            <if test="status != null">
                `status` = #{status,jdbcType=TINYINT},
            </if>
            <if test="createBy != null">
                create_by = #{createBy,jdbcType=BIGINT},
            </if>
            <if test="createTime != null">
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy,jdbcType=BIGINT},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag,jdbcType=TINYINT},
            </if>
        </set>
        where id = #{id,jdbcType=BIGINT}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.sckw.slope.detection.model.dos.mysql.KwsThreshold">
        <!--@mbg.generated-->
        update kws_threshold
        set device_id   = #{deviceId,jdbcType=BIGINT},
            item_name   = #{itemName,jdbcType=VARCHAR},
            `level`     = #{level,jdbcType=INTEGER},
            `max`       = #{max,jdbcType=VARCHAR},
            `min`       = #{min,jdbcType=VARCHAR},
            phones      = #{phones,jdbcType=VARCHAR},
            `status`    = #{status,jdbcType=TINYINT},
            create_by   = #{createBy,jdbcType=BIGINT},
            create_time = #{createTime,jdbcType=TIMESTAMP},
            update_by   = #{updateBy,jdbcType=BIGINT},
            update_time = #{updateTime,jdbcType=TIMESTAMP},
            del_flag    = #{delFlag,jdbcType=TINYINT}
        where id = #{id,jdbcType=BIGINT}
    </update>

    <select id="selectListAll" resultMap="BaseResultMap">

        <where>
            <if test="thresholdQuery.alarmInfo != null and thresholdQuery.alarmInfo !=''">
                and title = #{thresholdQuery.alarmInfo}
            </if>
            <if test="thresholdQuery.alarmLevel != null and thresholdQuery.alarmLevel !=''">
                and level = #{thresholdQuery.alarmLevel}
            </if>
            <if test="thresholdQuery.alarmLevel != null and thresholdQuery.alarmLevel !=''">
                and level = #{thresholdQuery.alarmLevel}
            </if>
        </where>
    </select>
</mapper>