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