<?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.base.mapper.BaseAlarmInfoMapper">
    
    <resultMap type="BaseAlarmInfo" id="BaseAlarmInfoResult">
        <result property="objId"    column="obj_id"    />
        <result property="busbarCode"    column="busbar_code"    />
        <result property="alarmAlias"    column="alarm_alias"    />
        <result property="alarmContent"    column="alarm_content"    />
        <result property="alarmType"    column="alarm_type"    />
        <result property="alarmValue"    column="alarm_value"    />
        <result property="judgMethod"    column="judg_method"    />
        <result property="isFlag"    column="is_flag"    />
        <result property="createdBy"    column="created_by"    />
        <result property="createdTime"    column="created_time"    />
        <result property="updatedBy"    column="updated_by"    />
        <result property="updatedTime"    column="updated_time"    />
    </resultMap>

    <sql id="selectBaseAlarmInfoVo">
        select obj_id, busbar_code, alarm_alias, alarm_content, alarm_type, alarm_value, judg_method, is_flag, created_by, created_time, updated_by, updated_time from base_alarm_info
    </sql>

    <select id="selectBaseAlarmInfoList" parameterType="BaseAlarmInfo" resultMap="BaseAlarmInfoResult">
        <include refid="selectBaseAlarmInfoVo"/>
        <where>  
            <if test="objId != null "> and obj_id = #{objId}</if>
            <if test="busbarCode != null "> and busbar_code = #{busbarCode}</if>
            <if test="alarmAlias != null  and alarmAlias != ''"> and alarm_alias = #{alarmAlias}</if>
            <if test="alarmContent != null  and alarmContent != ''"> and alarm_content = #{alarmContent}</if>
            <if test="alarmType != null "> and alarm_type = #{alarmType}</if>
            <if test="alarmValue != null "> and alarm_value = #{alarmValue}</if>
            <if test="judgMethod != null "> and judg_method = #{judgMethod}</if>
            <if test="isFlag != null "> and is_flag = #{isFlag}</if>
            <if test="createdBy != null  and createdBy != ''"> and created_by = #{createdBy}</if>
            <if test="params.beginCreatedTime != null and params.beginCreatedTime != '' and params.endCreatedTime != null and params.endCreatedTime != ''"> and created_time between #{params.beginCreatedTime} and #{params.endCreatedTime}</if>
            <if test="updatedBy != null  and updatedBy != ''"> and updated_by = #{updatedBy}</if>
            <if test="params.beginUpdatedTime != null and params.beginUpdatedTime != '' and params.endUpdatedTime != null and params.endUpdatedTime != ''"> and updated_time between #{params.beginUpdatedTime} and #{params.endUpdatedTime}</if>
        </where>
    </select>
    
    <select id="selectBaseAlarmInfoByObjId" parameterType="Long" resultMap="BaseAlarmInfoResult">
        <include refid="selectBaseAlarmInfoVo"/>
        where obj_id = #{objId}
    </select>

    <insert id="insertBaseAlarmInfo" parameterType="BaseAlarmInfo">
        insert into base_alarm_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="objId != null">obj_id,</if>
            <if test="busbarCode != null">busbar_code,</if>
            <if test="alarmAlias != null">alarm_alias,</if>
            <if test="alarmContent != null">alarm_content,</if>
            <if test="alarmType != null">alarm_type,</if>
            <if test="alarmValue != null">alarm_value,</if>
            <if test="judgMethod != null">judg_method,</if>
            <if test="isFlag != null">is_flag,</if>
            <if test="createdBy != null">created_by,</if>
            <if test="createdTime != null">created_time,</if>
            <if test="updatedBy != null">updated_by,</if>
            <if test="updatedTime != null">updated_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="objId != null">#{objId},</if>
            <if test="busbarCode != null">#{busbarCode},</if>
            <if test="alarmAlias != null">#{alarmAlias},</if>
            <if test="alarmContent != null">#{alarmContent},</if>
            <if test="alarmType != null">#{alarmType},</if>
            <if test="alarmValue != null">#{alarmValue},</if>
            <if test="judgMethod != null">#{judgMethod},</if>
            <if test="isFlag != null">#{isFlag},</if>
            <if test="createdBy != null">#{createdBy},</if>
            <if test="createdTime != null">#{createdTime},</if>
            <if test="updatedBy != null">#{updatedBy},</if>
            <if test="updatedTime != null">#{updatedTime},</if>
         </trim>
    </insert>

    <update id="updateBaseAlarmInfo" parameterType="BaseAlarmInfo">
        update base_alarm_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="busbarCode != null">busbar_code = #{busbarCode},</if>
            <if test="alarmAlias != null">alarm_alias = #{alarmAlias},</if>
            <if test="alarmContent != null">alarm_content = #{alarmContent},</if>
            <if test="alarmType != null">alarm_type = #{alarmType},</if>
            <if test="alarmValue != null">alarm_value = #{alarmValue},</if>
            <if test="judgMethod != null">judg_method = #{judgMethod},</if>
            <if test="isFlag != null">is_flag = #{isFlag},</if>
            <if test="createdBy != null">created_by = #{createdBy},</if>
            <if test="createdTime != null">created_time = #{createdTime},</if>
            <if test="updatedBy != null">updated_by = #{updatedBy},</if>
            <if test="updatedTime != null">updated_time = #{updatedTime},</if>
        </trim>
        where obj_id = #{objId}
    </update>

    <delete id="deleteBaseAlarmInfoByObjId" parameterType="Long">
        delete from base_alarm_info where obj_id = #{objId}
    </delete>

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