<?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.salpa.subject.mapper.WarningMapper">

    <resultMap type="com.salpa.subject.domain.MonitorWarning" id="MonitorWarningResult">
        <id     property="id"            column="id"             />
        <result property="warningName"          column="warning_name"           />
        <result property="warningSubject"   column="warning_subject"    />
        <result property="warningDataSource"             column="warning_data_source"              />
        <result property="warningTime"              column="warning_time"                />
        <result property="warningContent"             column="warning_content"              />
        <result property="warningStatus"             column="warning_status"              />
        <result property="handlingUser"             column="handling_user"              />
    </resultMap>
    
    <select id="warningList" resultMap="MonitorWarningResult">
        SELECT id,warning_name,warning_subject,warning_data_source,warning_time,warning_content,warning_status,handling_user
        FROM monitor_warning ORDER BY warning_status
    </select>

    <update id="updateStatus">
        UPDATE monitor_warning SET warning_status = 1,handling_user = #{userName}
        WHERE id = #{id}
    </update>

    <insert id="addWarning" parameterType="com.salpa.subject.domain.MonitorWarning">
        INSERT INTO monitor_warning(warning_name,warning_subject,warning_data_source,warning_time,warning_content)
        VALUES (#{warningName},#{warningSubject},#{warningDataSource},#{warningTime},#{warningContent})
    </insert>
</mapper>