分页查询

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>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值