<?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.AdwebPublicEnquiryRuleMapper">
    <select id="pageList" resultType="org.jeecg.modules.adweb.enquiry.entity.AdwebPublicEnquiryRule">
        SELECT t1.*, t2.num wasteEnquiryNum
        FROM `adweb_public_enquiry_rule` t1
        LEFT JOIN (SELECT
        t1.reason,count(*) num
        FROM
        (
        SELECT SUBSTRING_INDEX(effective_reason,'-',-1) reason
        FROM `adweb_enquiry`
        WHERE `status` = 1 AND user_effective = 0 AND sys_effective = 1 AND waste_enquiry_type = 'keyword'
        ) t1 GROUP BY t1.reason) t2
        ON t2.reason = t1.word WHERE t1.`status` != 0
        <if test="word != null and word != ''">
            AND t1.word like CONCAT('%', #{word}, '%')
        </if>
        <if test="blackOrWhiteList != null">
            AND t1.black_or_white_list = #{blackOrWhiteList}
        </if>
        <if test="isEnable != null">
            AND t1.is_enable = #{isEnable}
        </if>
        <if test="useStatus != null">
            AND t1.use_status = #{useStatus}
        </if>
        <if test="column != null and column != ''">
            ORDER BY
            <if test="column == 'createTime'">
                t1.create_time ${order}
            </if>
            <if test="column == 'isEnable'">
                t1.is_enable ${order}
            </if>
            <if test="column == 'useStatus'">
                t1.use_status ${order}
            </if>
            <if test="column == 'blackOrWhiteList'">
                t1.black_or_white_list ${order}
            </if>
        </if>
    </select>
</mapper>
