TODO 列出日志文件

This commit is contained in:
wangliwen 2022-11-08 15:20:43 +08:00
parent 45a8f3f6cb
commit dfe77f31a2
1 changed files with 15 additions and 1 deletions

View File

@ -9,21 +9,27 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@Api(tags = "管理员后台") @Api(tags = "管理员后台")
@RestController @RestController
@RequestMapping("/admin") @RequestMapping("/admin")
public class AdminController { public class AdminController {
private static final Logger logger = LoggerFactory.getLogger(AdminController.class); private static final Logger logger = LoggerFactory.getLogger(AdminController.class);
private static final String pwd = System.getProperty("user.dir");
@Autowired @Autowired
private UpdateUtil updateUtil; private UpdateUtil updateUtil;
@Value("${spring.profiles.active}") @Value("${spring.profiles.active}")
private String active; // 现有生效 private String active; // 现有生效
/** /**
* @param updateFile 更新包下载地址 * @param updateFile 更新包下载地址
* @param active 重启完成后的配置环境 * @param active 重启完成后的配置环境
@ -38,4 +44,12 @@ public class AdminController {
return new Result<String>().ok(String.valueOf(success)); return new Result<String>().ok(String.valueOf(success));
} }
@GetMapping(value = "logFiles")
public Result<List<String>> logFiles() {
List<String> result = new ArrayList<>();
File file = new File(pwd + File.separator + "logs");
File[] tempFile = file.listFiles();
return new Result<List<String>>().ok(result);
}
} }