<?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="org.jeecg.modules.adweb.enquiry.mapper.AdwebPublicBlackIpMapper">
    <select id="pageList" resultType="org.jeecg.modules.adweb.enquiry.entity.AdwebPublicBlackIp">
        SELECT t1.*, t2.num wasteEnquiryNum
        FROM `adweb_black_ip` t1
                 LEFT JOIN (SELECT from_ip, COUNT(*) num
                            FROM `adweb_enquiry`
                            WHERE `status` = 1
                              AND user_effective = 0
                              AND sys_effective = 1
                              AND waste_enquiry_type = 'ip'
                            GROUP BY from_ip) t2
                           ON t1.ip = t2.from_ip
        WHERE t1.`status` = 1
        <if test="ip != null and ip != ''">
            AND t1.ip like CONCAT('%', #{ip}, '%')
        </if>
        <if test="blackOrWhite != null">
            AND t1.black_or_white = #{blackOrWhite}
        </if>
        <if test = "column != null and column != ''">
              ORDER BY
              <if test = "column == 'createTime'">
                t1.create_time ${order}
              </if>
               <if test = "column == 'ip'">
                t1.ip ${order}
              </if>
        </if>
    </select>
</mapper>
