<?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.project.aspen.mapper.TElecdashboardAlarmMapper">
    
    <resultMap type="TElecdashboardAlarm" id="TElecdashboardAlarmResult">
        <result property="id"    column="id"    />
        <result property="alarmValue"    column="alarm_value"    />
        <result property="alarmTime"    column="alarm_time"    />
        <result property="code"    column="code"    />
        <result property="description"    column="description"    />
        <result property="deptName" column="dept_name" />
    </resultMap>

    <sql id="selectTElecdashboardAlarmVo">
        select d.id, d.alarm_value, d.code, d.description, d.alarm_time from t_elecdashboard_alarm d
    </sql>

    <select id="selectTElecdashboardAlarmList" parameterType="TElecdashboardAlarm" resultMap="TElecdashboardAlarmResult">
        <include refid="selectTElecdashboardAlarmVo"/>
        <where>  
            <if test="alarmValue != null "> and alarm_value = #{alarmValue}</if>
            <if test="code != null "> and code = #{code}</if>
            <if test="description != null "> and description = #{description}</if>
        </where>
    </select>
    
    <select id="selectTElecdashboardAlarmById" parameterType="Long" resultMap="TElecdashboardAlarmResult">
        <include refid="selectTElecdashboardAlarmVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTElecdashboardAlarm" parameterType="TElecdashboardAlarm">
        insert into t_elecdashboard_alarm
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="alarmValue != null">alarm_value,</if>
            <if test="code != null">code,</if>
            <if test="description != null">description,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="alarmValue != null">#{alarmValue},</if>
            <if test="code != null">#{code},</if>
            <if test="description != null">#{description},</if>
         </trim>
    </insert>

    <update id="updateTElecdashboardAlarm" parameterType="TElecdashboardAlarm">
        update t_elecdashboard_alarm
        <trim prefix="SET" suffixOverrides=",">
            <if test="alarmValue != null">alarm_value = #{alarmValue},</if>
            <if test="code != null">code = #{code},</if>
            <if test="description != null">description = #{description},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteTElecdashboardAlarmById" parameterType="Long">
        update t_elecdashboard_alarm set del_flag = 2 where id = #{id}
    </update>

    <update id="deleteTElecdashboardAlarmByIds" parameterType="String">
        update t_elecdashboard_alarm set del_flag = 2 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>