Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-11-10 09:16:57 +08:00
commit 83a24ecc8c
2 changed files with 21 additions and 18 deletions

View File

@ -30,21 +30,10 @@ public class AdminController {
@Value("${spring.profiles.active}") @Value("${spring.profiles.active}")
private String active; // 现有生效 private String active; // 现有生效
/**
// /** * @param params updateFile 更新包下载地址 active 重启完成后的配置环境
// * @param updateFile 更新包下载地址 * @return
// * @param active 重启完成后的配置环境 */
// * @return
// */
// @PostMapping(value = "/update")
// public Result<String> update(String updateFile, String active) {
// if (StringUtils.isEmpty(active)) {
// active = this.active;
// }
// boolean success = updateUtil.update(updateFile, active);
// return new Result<String>().ok(String.valueOf(success));
// }
@PostMapping(value = "/update") @PostMapping(value = "/update")
public Result<String> update(@RequestBody Map<String, String> params) { public Result<String> update(@RequestBody Map<String, String> params) {
String updateFile = params.containsKey("updateFile") ? params.get("updateFile") : null; String updateFile = params.containsKey("updateFile") ? params.get("updateFile") : null;
@ -69,7 +58,15 @@ public class AdminController {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
File file = new File(pwd + File.separator + "logs"); File file = new File(pwd + File.separator + "logs");
File[] tempFile = file.listFiles(); 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<List<String>>().ok(result); return new Result<List<String>>().ok(result);
} }
@ -92,8 +89,12 @@ public class AdminController {
headers.add("Expires", "0"); headers.add("Expires", "0");
headers.add("Last-Modified", new Date().toString()); headers.add("Last-Modified", new Date().toString());
headers.add("ETag", String.valueOf(System.currentTimeMillis())); 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_));
} }
} }

View File

@ -76,6 +76,8 @@ public class ShiroConfig {
filterMap.put("/resource/getApplyCameraList/**", "anon"); filterMap.put("/resource/getApplyCameraList/**", "anon");
filterMap.put("/resource/hls/getHls", "anon"); filterMap.put("/resource/hls/getHls", "anon");
filterMap.put("/admin/downloadLog", "anon"); // 下载运行日志文件
/** /**
* 资源上传 * 资源上传
*/ */