MyBatisPlus分页查询的几种方式
Posted 最小的帆也能远航
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyBatisPlus分页查询的几种方式相关的知识,希望对你有一定的参考价值。
public R moreCompany(JSONObject params) {
int pageNum = params.getIntValue("pageNum");
int pageSize = params.getIntValue("pageSize");
if (pageSize == 0) {
pageSize = 20;
}
Long userId = params.getLongValue("userId");
if (userId != 0) {
//查询个人简历中的期望城市
List<String> expectCityList = resumeDiyMapper.selectExpectCity(userId);
//判断是否查询到“期望城市”
if (expectCityList != null && expectCityList.size() > 0 && expectCityList.get(0) != null) {
params.put("expectCityList", expectCityList);
}
//查询个人简历中的期望职位
List<String> expectPositionList = resumeDiyMapper.selectExpectPosition(userId);
//判断是否查询到“期望职位”
if (expectPositionList != null && expectPositionList.size() > 0 && expectPositionList.get(0) != null) {
params.put("expectPositionList", expectPositionList);
}
}
//根据jy_resume_personal_info中的expectCity、expectPosition字段匹配jy_job中的name、workCity字段
Page<Map<String, Object>> moreCompany = companyDiyMapper.selectMoreCompany(new Page<>()
.setCurrent(pageNum)
.setSize(pageSize),params);
return R.ok(new PageInfo<>(moreCompany.getRecords()));
}
public R morePolicies(JSONObject params) {
int pageNum = params.getIntValue("pageNum");
int pageSize = params.getIntValue("pageSize");
if (pageSize == 0) {
pageSize = 20;
}
PageHelper.startPage(pageNum, pageSize);
Page<Policy> policyPage = new Policy().selectPage(new Page<Policy>()
.setSize(pageSize)
.setCurrent(pageNum),
new QueryWrapper<Policy>()
.eq("is_delete", 0)
.orderByDesc("view_count"));
for (Policy policy : policyPage.getRecords()) {
policy.setContent(currentUrl + "/appPolicy/policymodel/" + policy.getId());
}
return R.ok(policyPage);
}
以上是关于MyBatisPlus分页查询的几种方式的主要内容,如果未能解决你的问题,请参考以下文章