<?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.AlarmLogMapper">
    
    <resultMap type="AlarmLog" id="AlarmLogResult">
        <result property="id"    column="id"    />
        <result property="alarmTime"    column="alarm_time"    />
        <result property="alarmType"    column="alarm_type"    />
        <result property="alarmLevel"    column="alarm_level"    />
        <result property="alarmSource"    column="alarm_source"    />
        <result property="sourcePosition"    column="source_position"    />
        <result property="alarmTitle"    column="alarm_title"    />
        <result property="description"    column="description"    />
        <result property="snapshotUrl"    column="snapshot_url"    />
        <result property="handleStatus"    column="handle_status"    />
        <result property="handleBy"    column="handle_by"    />
        <result property="handleTime"    column="handle_time"    />
        <result property="handleRemark"    column="handle_remark"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectAlarmLogVo">
        select id, alarm_time, alarm_type, alarm_level, alarm_source, source_position, alarm_title, description, snapshot_url, handle_status, handle_by, handle_time, handle_remark, remark, create_time from robot_ops_alarm_log
    </sql>

    <select id="selectAlarmLogList" parameterType="AlarmLog" resultMap="AlarmLogResult">
        <include refid="selectAlarmLogVo"/>
        <where>  
            <if test="alarmTime != null "> and alarm_time = #{alarmTime}</if>
            <if test="alarmType != null  and alarmType != ''"> and alarm_type = #{alarmType}</if>
            <if test="alarmLevel != null  and alarmLevel != ''"> and alarm_level = #{alarmLevel}</if>
            <if test="alarmSource != null  and alarmSource != ''"> and alarm_source = #{alarmSource}</if>
            <if test="sourcePosition != null  and sourcePosition != ''"> and source_position = #{sourcePosition}</if>
            <if test="alarmTitle != null  and alarmTitle != ''"> and alarm_title = #{alarmTitle}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="snapshotUrl != null  and snapshotUrl != ''"> and snapshot_url = #{snapshotUrl}</if>
            <if test="handleStatus != null  and handleStatus != ''"> and handle_status = #{handleStatus}</if>
            <if test="handleBy != null  and handleBy != ''"> and handle_by = #{handleBy}</if>
            <if test="handleTime != null "> and handle_time = #{handleTime}</if>
            <if test="handleRemark != null  and handleRemark != ''"> and handle_remark = #{handleRemark}</if>
        </where>
    </select>
    
    <select id="selectAlarmLogById" parameterType="Long" resultMap="AlarmLogResult">
        <include refid="selectAlarmLogVo"/>
        where id = #{id}
    </select>

    <insert id="insertAlarmLog" parameterType="AlarmLog" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_alarm_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="alarmTime != null">alarm_time,</if>
            <if test="alarmType != null">alarm_type,</if>
            <if test="alarmLevel != null">alarm_level,</if>
            <if test="alarmSource != null">alarm_source,</if>
            <if test="sourcePosition != null">source_position,</if>
            <if test="alarmTitle != null">alarm_title,</if>
            <if test="description != null">description,</if>
            <if test="snapshotUrl != null">snapshot_url,</if>
            <if test="handleStatus != null">handle_status,</if>
            <if test="handleBy != null">handle_by,</if>
            <if test="handleTime != null">handle_time,</if>
            <if test="handleRemark != null">handle_remark,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="alarmTime != null">#{alarmTime},</if>
            <if test="alarmType != null">#{alarmType},</if>
            <if test="alarmLevel != null">#{alarmLevel},</if>
            <if test="alarmSource != null">#{alarmSource},</if>
            <if test="sourcePosition != null">#{sourcePosition},</if>
            <if test="alarmTitle != null">#{alarmTitle},</if>
            <if test="description != null">#{description},</if>
            <if test="snapshotUrl != null">#{snapshotUrl},</if>
            <if test="handleStatus != null">#{handleStatus},</if>
            <if test="handleBy != null">#{handleBy},</if>
            <if test="handleTime != null">#{handleTime},</if>
            <if test="handleRemark != null">#{handleRemark},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateAlarmLog" parameterType="AlarmLog">
        update robot_ops_alarm_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="alarmTime != null">alarm_time = #{alarmTime},</if>
            <if test="alarmType != null">alarm_type = #{alarmType},</if>
            <if test="alarmLevel != null">alarm_level = #{alarmLevel},</if>
            <if test="alarmSource != null">alarm_source = #{alarmSource},</if>
            <if test="sourcePosition != null">source_position = #{sourcePosition},</if>
            <if test="alarmTitle != null">alarm_title = #{alarmTitle},</if>
            <if test="description != null">description = #{description},</if>
            <if test="snapshotUrl != null">snapshot_url = #{snapshotUrl},</if>
            <if test="handleStatus != null">handle_status = #{handleStatus},</if>
            <if test="handleBy != null">handle_by = #{handleBy},</if>
            <if test="handleTime != null">handle_time = #{handleTime},</if>
            <if test="handleRemark != null">handle_remark = #{handleRemark},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAlarmLogById" parameterType="Long">
        delete from robot_ops_alarm_log where id = #{id}
    </delete>

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