public static int pageSize = 10;
Map<String, Object> mapToQuery = new HashMap<String, Object>();
if(!StringUtils.isEmpty(payType)){
mapToQuery.put("otherType", payTypeInt);
}
mapToQuery.put("orderid", orderid);
mapToQuery.put("platformid", platformid);
mapToQuery.put("startTime", startTime);
mapToQuery.put("endTime", endTime);
mapToQuery.put("index", start);
mapToQuery.put("pageSize", pageSize);
count = payOrderMapper.queryCount(mapToQuery);
List<PayOrder> list = payOrderMapper.queryPagination(mapToQuery);
totalpage = count % pageSize == 0 ? count/pageSize : (count - count % pageSize)/pageSize + 1;
Map<String, Object> m = new HashMap<String, Object>();
m.put("pay", list);
m.put("totalPage", totalpage);
m.put("count", count);
writeJsonForResponse(m, response);
<select id="queryCount" resultType="java.lang.Integer" parameterType="java.util.Map">
SELECT COUNT(1) FROM pay_order T WHERE 1=1
<if test="otherType != null">
AND T.type = #{otherType,jdbcType=INTEGER}
</if>
<if test="platformid != null">
AND T.platformid = #{platformid,jdbcType=VARCHAR}
</if>
<if test="orderid != null">
AND T.orderid = #{orderid,jdbcType=VARCHAR}
</if>
<if test="startTime != null">
AND T.create_time >= STR_TO_DATE(#{startTime,jdbcType=VARCHAR},'%Y-%c-%d')
</if>
<if test="endTime != null">
<![CDATA[ AND T.create_time <= STR_TO_DATE(#{endTime,jdbcType=VARCHAR},'%Y-%c-%d')]]>
</if>
AND delete_flag = 0
</select>
<select id="queryPagination" resultMap="BaseResultMap" parameterType="java.util.Map">
select <include refid="Base_Column_List" />
from pay_order T
WHERE 1=1
<if test="otherType != null">
AND T.type = #{otherType,jdbcType=INTEGER}
</if>
<if test="platformid != null">
AND T.platformid = #{platformid,jdbcType=VARCHAR}
</if>
<if test="orderid != null">
AND T.orderid = #{orderid,jdbcType=VARCHAR}
</if>
<if test="startTime != null">
AND T.create_time >= STR_TO_DATE(#{startTime,jdbcType=VARCHAR},'%Y-%c-%d')
</if>
<if test="endTime != null">
<![CDATA[ AND T.create_time <= STR_TO_DATE(#{endTime,jdbcType=VARCHAR},'%Y-%c-%d')]]>
</if>
AND delete_flag = 0
order by T.create_time DESC, T.update_time desc
LIMIT #{index,jdbcType=BIGINT}, #{pageSize,jdbcType=BIGINT}
</select>