diff --git a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java index 77305f4c..4bd66f5a 100644 --- a/renren-admin/src/main/java/io/renren/common/controller/AdminController.java +++ b/renren-admin/src/main/java/io/renren/common/controller/AdminController.java @@ -30,21 +30,10 @@ public class AdminController { @Value("${spring.profiles.active}") private String active; // 现有生效 - -// /** -// * @param updateFile 更新包下载地址 -// * @param active 重启完成后的配置环境 -// * @return -// */ -// @PostMapping(value = "/update") -// public Result update(String updateFile, String active) { -// if (StringUtils.isEmpty(active)) { -// active = this.active; -// } -// boolean success = updateUtil.update(updateFile, active); -// return new Result().ok(String.valueOf(success)); -// } - + /** + * @param params updateFile 更新包下载地址 active 重启完成后的配置环境 + * @return + */ @PostMapping(value = "/update") public Result update(@RequestBody Map params) { String updateFile = params.containsKey("updateFile") ? params.get("updateFile") : null; @@ -69,7 +58,15 @@ public class AdminController { List result = new ArrayList<>(); File file = new File(pwd + File.separator + "logs"); File[] tempFile = file.listFiles(); - result = Arrays.asList(tempFile).stream().filter(index -> index.isFile()).map(index -> index.getName()).collect(Collectors.toList()); + result = Arrays.asList(tempFile) + .stream() + .filter(index -> index.isFile() && index.getName().endsWith(".log")) + .sorted(Comparator.comparing(x -> { + File index = (File) x; + return index.lastModified(); + }).reversed()) + .map(index -> index.getName()) + .collect(Collectors.toList()); return new Result>().ok(result); } @@ -92,8 +89,12 @@ public class AdminController { headers.add("Expires", "0"); headers.add("Last-Modified", new Date().toString()); headers.add("ETag", String.valueOf(System.currentTimeMillis())); - return ResponseEntity.ok().headers(headers).contentLength(file_.length()).contentType(MediaType.parseMediaType("application/octet-stream")).body(new FileSystemResource(file_)); - + return ResponseEntity + .ok() + .headers(headers) + .contentLength(file_.length()) + .contentType(MediaType.parseMediaType("application/octet-stream")) + .body(new FileSystemResource(file_)); } } diff --git a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java index 47656484..3ff49784 100644 --- a/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java +++ b/renren-admin/src/main/java/io/renren/modules/security/config/ShiroConfig.java @@ -76,6 +76,8 @@ public class ShiroConfig { filterMap.put("/resource/getApplyCameraList/**", "anon"); filterMap.put("/resource/hls/getHls", "anon"); + filterMap.put("/admin/downloadLog", "anon"); // 下载运行日志文件 + /** * 资源上传 */