<?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.ozs.mapper.TerminalIgnoreAlarmMapper">
    <resultMap id="TerminalIgnoreAlarmResult" type="com.ozs.entity.TerminalIgnoreAlarm">
        <id column="id" property="id"/>
        <result column="terminal_code" property="terminalCode"/>
        <result column="terminal_name" property="terminalName"/>
        <result column="alarm_id" property="alarmId"/>
        <result column="ignore_time" property="ignoreTime"/>
        <result column="create_by" property="createBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_by" property="updateBy"/>
        <result column="update_time" property="updateTime"/>
        <result column="remark" property="remark"/>
    </resultMap>
    <select id="list" resultMap="TerminalIgnoreAlarmResult" >
        SELECT
        a.terminal_code,
        b.terminal_name,
        a.alarm_id,
        a.ignore_time,
        a.create_by,
        a.create_time,
        a.update_by,
        a.update_time,
        a.remark
        FROM terminal_ignore_alarm as a inner join
        base_terminal as b on a.terminal_code = b.terminal_code
        <where>
            <if test="terminalCode != null and terminalCode != ''">
                and a.terminal_code = #{terminalCode}
            </if>
        </where>
    </select>

    <select id="selectDetailByAlarmId" resultType="com.ozs.entity.vo.MsgAlarmDTO">
        select a.*,b.railway_name,t.terminal_code,bt.terminal_name,t.ignore_time
        from msg_alarm as a inner join
        base_railway_management as b on a.railway_code=b.railway_code left join
        terminal_ignore_alarm as t on a.alarm_id=t.alarm_id left join
        base_terminal as bt on t.terminal_code = bt.terminal_code
        where t.id = #{id}
    </select>

</mapper>
