<?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.its.safe.dao.mapper.safe.VmsSafeMapper">

    <select id="selectArea" resultType="com.its.safe.entity.safe.TbArea" fetchSize="500">
    <![CDATA[
        SELECT A.seq as seq,
               A.code as code,
               A.upper_code as upperCode,
               A.name as name,
               A.depth as depth,
               A.base_date as baseDate
        FROM area A
        WHERE 1=1
        ]]>
    </select>

    <select id="selectNewVmsSafeMessage" parameterType="java.lang.String" resultType="com.its.safe.entity.safe.TbReadCheck" fetchSize="20">
    <![CDATA[
        SELECT A.seq as seq,
               A.message_seq as messageSeq,
               A.system_id as systemId,
               A.request_time as requestTime,
               A.response_time as responseTime
        FROM read_check A
        WHERE 1=1
          AND A.system_id = #{systemId}
          AND A.request_time > now() - interval 24 hour
          AND A.response_time is NULL
        ]]>
    </select>

    <update id="updateConfirmNewVmsSafeMessage" parameterType="java.lang.Long">
    <![CDATA[
        UPDATE read_check
           set response_time = now()
        WHERE 1=1
          AND seq = #{seq}
        ]]>
    </update>

    <select id="selectVmsSafeMessage" parameterType="java.lang.Long" resultType="com.its.safe.entity.safe.TbMessage" fetchSize="20">
    <![CDATA[
        SELECT A.seq as seq,
               A.status as status,
               A.msg_type as msgType,
               A.pre_seq as requestTime,
               A.title as title,
               A.textboard40_kr as textBoard40Kr,
               A.textboard40_kr_1 as textBoard40Kr1,
               A.textboard40_kr_2 as textBoard40Kr2,
               A.area_desc as areaDesc,
               A.area_code as areaCode,
               A.create_time as createTime
        FROM message A
        WHERE 1=1
          AND A.seq = #{messageSeq}
        ]]>
    </select>

    <insert id="insertConnCheck" parameterType="java.lang.String">
    <![CDATA[
        INSERT INTO conn_check (
            system_id
        )
        VALUES (
                   #{systemId}
               )
        ]]>
    </insert>

</mapper>
