ServerLogService { public QueryResult<ServerLog> query(int page, int size, ServerLog model) { File[] logFiles = logFileContent.listFiles(); int count = logFiles.length; int skipCount = (page - 1) * size; int totalPages = (int) Math.ceil(count / (double) size); if (skipCount > count) { page = totalPages; skipCount = (page - 1) * size; } List<ServerLog> serverLogList = Stream.of(logFiles) .sorted(Comparator.comparing(FileUtil::lastModifiedTime, Comparator.reverseOrder())) .skip(skipCount) .limit(size) .map(logFile -> { ServerLog serverLog = new ServerLog(); serverLog.setFileName(logFile.getName()); serverLog.setSize(logFile.length()); serverLog.setLastModifiedTime(FileUtil.lastModifiedTime(logFile)); try { serverLog.setCanonicalPath(logFile.getCanonicalPath()); } catch (IOException e) { e.printStackTrace(); } return serverLog; }) .collect(Collectors.toList()); return new QueryResult(serverLogList, count, page, totalPages); }  List<ServerLog> findAll(ServerLog model); QueryResult<ServerLog> query(int page, int size, ServerLog model); void downloadLogFile(String fileName, HttpServletResponse response);  }
@Test public void query() { QueryResult<ServerLog> query = serverLogService.query(1, 3, null); log.info("{}", query); }