MongoLogServiceImpl implements LogService { @Override public CommonPager<LogVO> listByPage(final ConditionQuery query) { CommonPager<LogVO> voCommonPager = new CommonPager<>(); final String mongoTableName = RepositoryPathUtils.buildMongoTableName(query.getApplicationName()); final PageParameter pageParameter = query.getPageParameter(); Query baseQuery = new Query(); if (StringUtils.isNoneBlank(query.getTransId())) { baseQuery.addCriteria(new Criteria("transId").is(query.getTransId())); } final long totalCount = mongoTemplate.count(baseQuery, mongoTableName); if (totalCount <= 0) { return voCommonPager; } final int currentPage = pageParameter.getCurrentPage(); final int pageSize = pageParameter.getPageSize(); int start = (currentPage - 1) * pageSize; voCommonPager.setPage(PageHelper.buildPage(query.getPageParameter(), (int) totalCount)); baseQuery.skip(start).limit(pageSize); final List<MongoAdapter> mongoAdapters = mongoTemplate.find(baseQuery, MongoAdapter.class, mongoTableName); if (CollectionUtils.isNotEmpty(mongoAdapters)) { final List<LogVO> recoverVOS = mongoAdapters .stream() .map(ConvertHelper::buildVO) .collect(Collectors.toList()); voCommonPager.setDataList(recoverVOS); } return voCommonPager; }  @Override CommonPager<LogVO> listByPage(final ConditionQuery query); @Override Boolean batchRemove(final List<String> ids, final String appName); @Override Boolean updateRetry(final String id, final Integer retry, final String appName);  }
@Test public void listByPage() { ConditionQuery query = new ConditionQuery(); query.setApplicationName("alipay-service"); PageParameter pageParameter = new PageParameter(1, 5); query.setPageParameter(pageParameter); final CommonPager<LogVO> voCommonPager = logService.listByPage(query); }