<?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="cn.roadm.mapper.InterfaceQueryMapper">

    <resultMap type="InterfaceQuery" id="interfaceQuery">
        <id column="id" property="id"/>
        <id column="spId" property="spId"/>
        <id column="mdns" property="mdns"/>
        <id column="create_time" property="createDate"/>
        <result column="content" property="content"/>
        <result column="reason" property="reason"/>
    </resultMap>


    <select id="listPageInterfases" parameterType="InterfaceQuery"  resultMap="interfaceQuery">
        SELECT * from  sms_interface_query
        <where>
        	1=1
            <if test="mdns!= '' and mdns != null">
                and mdns like CONCAT(#{mdns},'%')
            </if>
            <if test="spId!= '' and spId != null">
                and spId =#{spId}
            </if>
            <if test="content != null and content != ''">
               and content like CONCAT('%',#{content},'%')
            </if>
            <if test="beginTime!=null and beginTime!=''">
                and create_time&gt;=str_to_date(#{beginTime},'%Y-%m-%d')
            </if>
            <if test="endTime!=null and endTime!=''">
                and create_time&lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        order by create_time desc
    </select>

  <select id="export" parameterType="InterfaceQuery"  resultType="Map">
        SELECT * from  sms_interface_query
        <where>
        	1=1
            <if test="mdns!= '' and mdns != null">
                and mdns like CONCAT(#{mdns},'%')
            </if>
            <if test="spId!= '' and spId != null">
                and spId =#{spId}
            </if>
            <if test="content != null and content != ''">
               and content like CONCAT('%',#{content},'%')
            </if>
            <if test="beginTime!=null and beginTime!=''">
                and create_time&gt;=str_to_date(#{beginTime},'%Y-%m-%d')
            </if>
            <if test="endTime!=null and endTime!=''">
                and create_time&lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        order by create_time desc
    </select>
    
    <select id="exportInterfaceQueryCount" parameterType="InterfaceQuery"  resultType="Integer">
        SELECT count(1) from  sms_interface_query
        <where>
        	1=1
            <if test="mdns!= '' and mdns != null">
                and mdns like CONCAT(#{mdns},'%')
            </if>
            <if test="spId!= '' and spId != null">
                and spId =#{spId}
            </if>
            <if test="content != null and content != ''">
               and content like CONCAT('%',#{content},'%')
            </if>
            <if test="beginTime!=null and beginTime!=''">
                and create_time&gt;=str_to_date(#{beginTime},'%Y-%m-%d')
            </if>
            <if test="endTime!=null and endTime!=''">
                and create_time&lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
        </where>
        
    </select>
  
  <select id="exportInterfaceQuery" parameterType="InterfaceQuery"  resultType="Map">
        SELECT cast(siq.id as char) id,mdns,content,reason,create_time,spid from  sms_interface_query siq
        <where>
        	1=1
            <if test="mdns!= '' and mdns != null">
                and mdns like CONCAT(#{mdns},'%')
            </if>
            <if test="spId!= '' and spId != null">
                and spId =#{spId}
            </if>
            <if test="content != null and content != ''">
               and content like CONCAT('%',#{content},'%')
            </if>
            <if test="beginTime!=null and beginTime!=''">
                and create_time&gt;=str_to_date(#{beginTime},'%Y-%m-%d')
            </if>
            <if test="endTime!=null and endTime!=''">
                and create_time&lt;DATE_ADD(str_to_date(#{endTime},'%Y-%m-%d'),INTERVAL 1 DAY)
            </if>
            <if test="endId != null">
                and siq.id &lt;  #{endId}
        	</if>
        </where>
        order by siq.id desc
        <if test="exportExcelSize != null ">
            limit #{exportExcelSize}
        </if>
    </select>  
</mapper>