use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project springboot-learning by lyb-geek.
the class BookServiceImpl method pageBook.
@Override
public PageResult<BookDTO> pageBook(PageQuery<BookDTO> pageQuery) {
BookDTO bookDTO = pageQuery.getQueryParams();
Wrapper<Book> wrapper = wrapperQueryCondition(bookDTO);
IPage<Book> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<Book> bookIPage = baseMapper.selectPage(page, wrapper);
if (bookIPage != null) {
List<BookDTO> bookDTOS = new ArrayList<>();
if (CollectionUtils.isNotEmpty(bookIPage.getRecords())) {
bookDTOS = BeanMapperUtils.mapList(bookIPage.getRecords(), BookDTO.class);
}
return PageUtil.INSTANCE.getPage(bookIPage, bookDTOS);
}
return null;
}
use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project springboot-learning by lyb-geek.
the class MsgLogController method pagemsgLogs.
@ApiOperation(value = "查找msgLog", tags = { "msgLog" }, nickname = "pageMsgLogs")
@ApiResponses(value = { @ApiResponse(code = 200, message = "操作是否成功,200:成功,否则失败") })
@ApiImplicitParams({ @ApiImplicitParam(name = "curPage", value = "页数", defaultValue = "1", dataTypeClass = Long.class, paramType = "query", required = true), @ApiImplicitParam(name = "pageSize", value = "条数", defaultValue = "20", dataTypeClass = Long.class, paramType = "query", required = true) })
@GetMapping(value = "/page", produces = { "application/json" })
public Page<MsgLog> pagemsgLogs(@RequestParam(value = "curPage") Long curPage, @RequestParam(value = "pageSize") Long pageSize) {
Page page = new Page(curPage, pageSize);
Page<MsgLog> pageMsg = (Page<MsgLog>) msgLogService.page(page);
return pageMsg;
}
use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project forum by saysky.
the class BaseService method findAll.
/**
* 根据查询条件分页获取
*
* @param page
* @param condition
* @return
*/
default Page<E> findAll(Page<E> page, QueryCondition<E> condition) {
E e = condition.getData();
SearchVo searchVo = condition.getSearchVo();
// 对指定字段查询
QueryWrapper<E> queryWrapper = getQueryWrapper(e);
// 查询日期范围
if (searchVo != null) {
String startDate = searchVo.getStartDate();
String endDate = searchVo.getEndDate();
if (StrUtil.isNotBlank(startDate) && StrUtil.isNotBlank(endDate)) {
Date start = DateUtil.parse(startDate);
Date end = DateUtil.parse(endDate);
queryWrapper.between("create_time", start, end);
}
}
return (Page<E>) getRepository().selectPage(page, queryWrapper);
}
use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project RG by ADrWondertainment.
the class AnswerServiceImpl method getAnswersByUserID.
@Override
public Result getAnswersByUserID(Integer id, Integer pageNum, Integer size) {
IPage<Answer> page = new Page(pageNum, size);
QueryWrapper<Answer> query = Wrappers.query();
query.eq("uid", id);
IPage<Answer> answerIPage = answerMapper.selectPage(page, query);
if (answerIPage == null) {
throw new BackException(ErrorCode.TEMPLATE_SELECT_FAILURE, "分页数据查询失败");
}
List<Answer> records = answerIPage.getRecords();
JSONArray jsonArray = JSONUtil.parseArray(records);
System.out.println(JSONUtil.toJsonPrettyStr(jsonArray));
ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
return result;
}
use of com.baomidou.mybatisplus.extension.plugins.pagination.Page in project RG by ADrWondertainment.
the class SheetServiceImpl method getSheetsInPages.
@Override
public Result getSheetsInPages(Integer id, Integer pageIndex, Integer sizePerPage) {
IPage<Sheet> page = new Page(pageIndex, sizePerPage);
QueryWrapper<Sheet> query = Wrappers.query();
query.eq("uid", id);
IPage<Sheet> sheetIPage = sheetMapper.selectPage(page, query);
if (sheetIPage == null) {
throw new BackException(ErrorCode.SHEET_SELECT_FAILURE, "分页数据查询失败");
}
JSONArray jsonArray = JSONUtil.parseArray(sheetIPage.getRecords());
ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
return result;
}
Aggregations