pageHelp 获取count的时候会默认把order by 过滤掉,有可能会导致实际总数与查出来的总数不一样的情况,如下面的SQL:
SELECT a.* FROM ( SELECT card , name , sex , activity_level , store_name , member_id , trade_total , create_card_time FROM report_member_advance WHERE company_id = #{companyId} AND store_id = #{storeId} ORDER BY id DESC ) a GROUP BY a.member_id HAVING 1 = 1 <if test="quantity != null and quantity == 5"> -- 大于4次 AND trade_total <![CDATA[ > ]]> 4 </if> <if test="quantity != null and quantity == 99"> -- 消费总数 AND trade_total <![CDATA[<>]]> 0 </if> <if test="quantity != null and quantity != 99 and quantity != 5"> -- 0-4次 AND trade_total = #{quantity} </if>
pageHelp 查出来的count 是103,复制sql执行是101,通过跟踪源码得知,作者是做了后门的,只要在需要不过滤的order by 前面 添加 /*keep orderby*/ 注解后,pageHelp 就会忽略不过滤order by&