<?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.traceability.mapper.BaseAlarminfoMapper">
    
    <resultMap type="BaseAlarminfo" id="BaseAlarminfoResult">
        <result property="objId"    column="objId"    />
        <result property="alarmCode"    column="alarmCode"    />
        <result property="alarmMessage"    column="alarmMessage"    />
        <result property="alarmPropose"    column="alarmPropose"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBaseAlarminfoVo">
        select objId, alarmCode, alarmMessage, alarmPropose, remark from base_alarminfo
    </sql>

    <select id="selectBaseAlarminfoList" parameterType="BaseAlarminfo" resultMap="BaseAlarminfoResult">
        <include refid="selectBaseAlarminfoVo"/>
        <where>  
            <if test="alarmCode != null  and alarmCode != ''"> and alarmCode = #{alarmCode}</if>
        </where>
    </select>
    
    <select id="selectBaseAlarminfoByObjId" parameterType="Long" resultMap="BaseAlarminfoResult">
        <include refid="selectBaseAlarminfoVo"/>
        where objId = #{objId}
    </select>

    <select id="selectBaseAlarmInfoByAlarmCode" parameterType="String" resultMap="BaseAlarminfoResult">
        <include refid="selectBaseAlarminfoVo"/>
        where alarmCode = #{alarmCode}
    </select>
        
    <insert id="insertBaseAlarminfo" parameterType="BaseAlarminfo" useGeneratedKeys="true" keyProperty="objId">
        insert into base_alarminfo
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="alarmCode != null">alarmCode,</if>
            <if test="alarmMessage != null">alarmMessage,</if>
            <if test="alarmPropose != null">alarmPropose,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="alarmCode != null">#{alarmCode},</if>
            <if test="alarmMessage != null">#{alarmMessage},</if>
            <if test="alarmPropose != null">#{alarmPropose},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBaseAlarminfo" parameterType="BaseAlarminfo">
        update base_alarminfo
        <trim prefix="SET" suffixOverrides=",">
            <if test="alarmCode != null">alarmCode = #{alarmCode},</if>
            <if test="alarmMessage != null">alarmMessage = #{alarmMessage},</if>
            <if test="alarmPropose != null">alarmPropose = #{alarmPropose},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where objId = #{objId}
    </update>

    <delete id="deleteBaseAlarminfoByObjId" parameterType="Long">
        delete from base_alarminfo where objId = #{objId}
    </delete>

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

</mapper>