oracle数据库内部分页
//前端返回两个参数pageSize:每页数据量,pageNum:当前页码,
Map<String, Integer> betweenAndLast = PageUtil.getBetweenAndLast(pageSize, pageNum);
String begin = betweenAndLast.get("begin").toString();
String last = betweenAndLast.get("last").toString();
List<AccountInfoVO> listInfo = accountInfoMapper.getKeyWordInfo(begin, last);//查询数据
查询数据的sql
select *
from (select rownum rn, T.*
from (select t.taaccountid as accountCode,
t.individualorinstitution as accountType,
t.investorname as accountName,
t.appsheetserialno as applicationNumber,
t.transactioncfmdate as applicationDate,
t.f_custtype as clientType,
f.key_name as clientTypeName,
p.intercountyname || d.intercountyname as provincCity,
t.province as provinceNum,
p.intercountyname as provinceName,
t.city as cityNum,
d.intercountyname as cityName,
t.investorsbirthday as birthDate,
t.create_user as founderPeople,
t.create_time as founderTime,
t.modify_user as modifyPeople,
t.modify_time as modifyTime
from tc_pf_pb_ta_account t
left join tp_gl_county_code_map p
on t.province = p.intercode
left join tp_gl_county_code_map d
on t.city = d.intercode
left join tp_gl_exhib_datadict f
on f.key_id = t.f_custtype
where 1 = 1
order by case
when t.modify_time is not null then
t.modify_time
else
t.create_time
end desc) T) t
where t.rn between #{begin} and #{last}--分页从第几行开始、结束
PageUtil.java
/**
* 根据前端传的第几页和每页显示的条数,计算分页的区间
* @param limit 每页显示的条数
* @param page 第几页
* @return begin:第几条开始 last:第几条结束
**/
public static Map<String, Integer> getBetweenAndLast(Integer limit, Integer page) {
Map<String, Integer> map = new HashMap<>();
//从第几条开始
Integer begin = (limit * (page - 1)) + 1;
//第几条结束
Integer last = (limit * (page - 1)) + limit;
map.put("begin", begin);
map.put("last", last);
return map;
}
}