<?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">
	 
	<!-- 해당 부분의 namespace는 project package + Mapper Package + Mapper Interface 이름입니다. -->
	<mapper namespace="com.elt.ems.mapper.DevEtcMapper">
	
		<!-- 해당 부분의 id는 MapperClass의 함수 이름과 유사하여야 합니다. -->
	    <sql id="commonPagingHeader"  >
	      SELECT R1.* FROM (
	    </sql>
	    
	    <sql id="commonPagingFooter"  >
	      ) R1 LIMIT #{pgtl.startNo}, #{pgtl.listPerPage}
	    </sql> 
	    
		<!-- 해당 부분의 id는 MapperClass의 함수 이름과 유사하여야 합니다. -->
		<select id="listTelegramCount" parameterType="com.elt.ems.vo.SearchMapVo"  resultType="int">
      		
		      select count(inc) cnt
		      from pmswdb.tb_errhistory a
		      where 1=1
		      <if test="map != null">
		      	<if test="map.epname != null and map.epname != '' ">and epname like concat('%', #{map.epname}, '%')</if>
		      	<if test="map.errmsg != null and map.errmsg != '' ">and errmsg like concat('%', #{map.errmsg}, '%')</if>
		      	<if test="map.startDate != null"> and occurdate between #{map.startDate} and #{map.endDate} </if>
		      </if>
	            
		</select>
				
		<select id="listTelegram" parameterType="com.elt.ems.vo.SearchMapVo"  resultType="com.elt.ems.vo.TelegramVo">
	      <if test="pgtl != null">
	        <include refid="commonPagingHeader" /> 
	      </if>	      		
		      select *
		      from pmswdb.tb_errhistory a
		      where 1=1
		      <if test="map != null">
		      	<if test="map.epname != null and map.epname != '' ">and epname like concat('%', #{map.epname}, '%')</if>
		      	<if test="map.errmsg != null and map.errmsg != '' ">and errmsg like concat('%', #{map.errmsg}, '%')</if>
		      	<if test="map.startDate != null"> and occurdate between #{map.startDate} and #{map.endDate} </if>
		      </if>
		      order by inc desc 
		      
	      <if test="pgtl != null">
	        <include refid="commonPagingFooter" />
	      </if>		            
		</select>
		
	</mapper>