@Test public void listByPage() throws Exception { ConditionQuery query = new ConditionQuery(); query.setApplicationName("alipay-service"); PageParameter pageParameter = new PageParameter(1,1); query.setPageParameter(pageParameter); query.setRetry(2); query.setTransId("2075304338"); final CommonPager<LogVO> voCommonPager = logService.listByPage(query); }
@Override public CommonPager<LogVO> listByPage(final ConditionQuery query) { CommonPager<LogVO> commonPager = new CommonPager<>(); final String redisKeyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(query.getApplicationName()); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; Set<byte[]> keys; List<LogVO> voList; int totalCount; if (StringUtils.isBlank(query.getTransId())) { keys = jedisClient.keys((redisKeyPrefix + "*").getBytes()); if (keys.size() <= 0 || keys.size() < start) { return commonPager; } totalCount = keys.size(); voList = findByPage(keys, start, pageSize); } else { keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes()); totalCount = keys.size(); voList = findAll(keys); } if (keys.size() <= 0 || keys.size() < start) { return commonPager; } commonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); commonPager.setDataList(voList); return commonPager; }
RedisLogServiceImpl implements LogService { @Override public CommonPager<LogVO> listByPage(final ConditionQuery query) { CommonPager<LogVO> commonPager = new CommonPager<>(); final String redisKeyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(query.getApplicationName()); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; Set<byte[]> keys; List<LogVO> voList; int totalCount; if (StringUtils.isBlank(query.getTransId())) { keys = jedisClient.keys((redisKeyPrefix + "*").getBytes()); if (keys.size() <= 0 || keys.size() < start) { return commonPager; } totalCount = keys.size(); voList = findByPage(keys, start, pageSize); } else { keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes()); totalCount = keys.size(); voList = findAll(keys); } if (keys.size() <= 0 || keys.size() < start) { return commonPager; } commonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); commonPager.setDataList(voList); return commonPager; } }
RedisLogServiceImpl implements LogService { @Override public CommonPager<LogVO> listByPage(final ConditionQuery query) { CommonPager<LogVO> commonPager = new CommonPager<>(); final String redisKeyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(query.getApplicationName()); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; Set<byte[]> keys; List<LogVO> voList; int totalCount; if (StringUtils.isBlank(query.getTransId())) { keys = jedisClient.keys((redisKeyPrefix + "*").getBytes()); if (keys.size() <= 0 || keys.size() < start) { return commonPager; } totalCount = keys.size(); voList = findByPage(keys, start, pageSize); } else { keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes()); totalCount = keys.size(); voList = findAll(keys); } if (keys.size() <= 0 || keys.size() < start) { return commonPager; } commonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); commonPager.setDataList(voList); return commonPager; }  }
RedisLogServiceImpl implements LogService { @Override public CommonPager<LogVO> listByPage(final ConditionQuery query) { CommonPager<LogVO> commonPager = new CommonPager<>(); final String redisKeyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(query.getApplicationName()); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; Set<byte[]> keys; List<LogVO> voList; int totalCount; if (StringUtils.isBlank(query.getTransId())) { keys = jedisClient.keys((redisKeyPrefix + "*").getBytes()); if (keys.size() <= 0 || keys.size() < start) { return commonPager; } totalCount = keys.size(); voList = findByPage(keys, start, pageSize); } else { keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes()); totalCount = keys.size(); voList = findAll(keys); } if (keys.size() <= 0 || keys.size() < start) { return commonPager; } commonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); commonPager.setDataList(voList); return commonPager; }  @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); }
RedisLogServiceImpl implements LogService { @Override public CommonPager<LogVO> listByPage(final ConditionQuery query) { CommonPager<LogVO> commonPager = new CommonPager<>(); final String redisKeyPrefix = RepositoryPathUtils.buildRedisKeyPrefix(query.getApplicationName()); final int currentPage = query.getPageParameter().getCurrentPage(); final int pageSize = query.getPageParameter().getPageSize(); int start = (currentPage - 1) * pageSize; Set<byte[]> keys; List<LogVO> voList; int totalCount; if (StringUtils.isBlank(query.getTransId())) { keys = jedisClient.keys((redisKeyPrefix + "*").getBytes()); if (keys.size() <= 0 || keys.size() < start) { return commonPager; } totalCount = keys.size(); voList = findByPage(keys, start, pageSize); } else { keys = Sets.newHashSet(String.join(":", redisKeyPrefix, query.getTransId()).getBytes()); totalCount = keys.size(); voList = findAll(keys); } if (keys.size() <= 0 || keys.size() < start) { return commonPager; } commonPager.setPage(PageHelper.buildPage(query.getPageParameter(), totalCount)); commonPager.setDataList(voList); return commonPager; }  @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);  }