<?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="java.util.HashMap"  resultType="int">
      		
			select count(inc) cnt
			from pmswdb.tb_errhistory a
			where 1=1
	      	<if test="epname != null and epname != '' ">and epname like concat('%', #{epname}, '%')</if>
	      	<if test="errmsg != null and errmsg != '' ">and errmsg like concat('%', #{errmsg}, '%')</if>
	      	<if test="startDate != null"> and occurdate between concat(#{startDate}, ' 00:00:00') and concat(#{endDate}, ' 23:59:59')</if>
		</select>
				
		<select id="listTelegram" parameterType="java.util.HashMap"  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="epname != null and epname != '' ">and epname like concat('%', #{epname}, '%')</if>
			<if test="errmsg != null and errmsg != '' ">and errmsg like concat('%', #{errmsg}, '%')</if>
			<if test="startDate != null"> and occurdate between concat(#{startDate}, ' 00:00:00') and concat(#{endDate}, ' 23:59:59')</if>
		    order by inc desc 		      
	      <if test="pgtl != null">
	        <include refid="commonPagingFooter" />
	      </if>		            
		</select>
		
	</mapper>