JdbcRecoverTransactionServiceImpl implements RecoverTransactionService { @Override public CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query) { final String tableName = RepositoryPathUtils.buildDbTableName(query.getApplicationName()); final PageParameter pageParameter = query.getPageParameter(); StringBuilder sqlBuilder = new StringBuilder(); sqlBuilder.append("select id,target_class,target_method," + " retried_count,create_time,last_time,version,group_id,task_id from ") .append(tableName).append(" where 1= 1 "); if (StringUtils.isNoneBlank(query.getTxGroupId())) { sqlBuilder.append(" and group_id = ").append(query.getTxGroupId()); } if (Objects.nonNull(query.getRetry())) { sqlBuilder.append(" and retried_count < ").append(query.getRetry()); } final String sql = buildPageSql(sqlBuilder.toString(), pageParameter); CommonPager<TransactionRecoverVO> pager = new CommonPager<>(); final List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sql); if (CollectionUtils.isNotEmpty(mapList)) { pager.setDataList(mapList.stream() .map(this::buildByMap).collect(Collectors.toList())); } final Integer totalCount = jdbcTemplate.queryForObject(String.format("select count(1) from %s", tableName), Integer.class); pager.setPage(PageHelper.buildPage(pageParameter, totalCount)); return pager; }  @Override CommonPager<TransactionRecoverVO> listByPage(final RecoverTransactionQuery query); @Override Boolean batchRemove(final List<String> ids, final String applicationName); @Override Boolean updateRetry(final String id, final Integer retry, final String applicationName); void setDbType(final String dbType);  }
@Test public void listByPage() throws Exception { RecoverTransactionQuery query = new RecoverTransactionQuery(); PageParameter pageParameter = new PageParameter(1,10); query.setPageParameter(pageParameter); query.setApplicationName("wechat-service"); final CommonPager<TransactionRecoverVO> pager = recoverTransactionService.listByPage(query); Assert.assertNotNull(pager.getDataList()); }