refactor: 修改操作日志的后台导出excel
This commit is contained in:
@@ -77,10 +77,32 @@ public class SysLogsController extends BaseController {
|
||||
return ResponseDTO.ok(pageDTO);
|
||||
}
|
||||
|
||||
// @GetMapping("/download")
|
||||
// public ResponseEntity<InputStreamResource> downloadFile() throws IOException {
|
||||
// // 从文件系统或其他位置获取文件输入流
|
||||
// File file = new File("path/to/file");
|
||||
// InputStream inputStream = new FileInputStream(file);
|
||||
// CustomExcelUtil.wri
|
||||
//
|
||||
// // 创建一个 InputStreamResource 对象,将文件输入流包装在其中
|
||||
// InputStreamResource resource = new InputStreamResource(inputStream);
|
||||
//
|
||||
// // 返回 ResponseEntity 对象,其中包含 InputStreamResource 对象和文件名
|
||||
// return ResponseEntity.ok()
|
||||
// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + file.getName())
|
||||
// .contentType(MediaType.APPLICATION_OCTET_STREAM)
|
||||
// .contentLength(file.length())
|
||||
// .body(resource);
|
||||
// }
|
||||
/**
|
||||
* 可否改成以上的形式 TODO
|
||||
* @param response
|
||||
* @param query
|
||||
*/
|
||||
@Operation(summary = "操作日志导出")
|
||||
@AccessLog(title = "操作日志", businessType = BusinessTypeEnum.EXPORT)
|
||||
@PreAuthorize("@permission.has('monitor:operlog:export')")
|
||||
@PostMapping("/operationLogs/excel")
|
||||
@GetMapping("/operationLogs/excel")
|
||||
public void operationLogsExcel(HttpServletResponse response, OperationLogQuery query) {
|
||||
PageDTO<OperationLogDTO> pageDTO = logApplicationService.getOperationLogList(query);
|
||||
CustomExcelUtil.writeToResponse(pageDTO.getRows(), OperationLogDTO.class, response);
|
||||
|
||||
@@ -34,11 +34,11 @@ class MenuModelTest {
|
||||
@Test
|
||||
void testCheckExternalLinkWhenSuccessful() {
|
||||
MenuModel notExternalButWithoutHttpPrefix = new MenuModel();
|
||||
notExternalButWithoutHttpPrefix.setIsExternal(false);
|
||||
// notExternalButWithoutHttpPrefix.setIsExternal(false);
|
||||
notExternalButWithoutHttpPrefix.setPath("www.baidu.com");
|
||||
|
||||
MenuModel isExternalWithHttpPrefix = new MenuModel();
|
||||
isExternalWithHttpPrefix.setIsExternal(true);
|
||||
// isExternalWithHttpPrefix.setIsExternal(true);
|
||||
isExternalWithHttpPrefix.setPath("http://www.baidu.com");
|
||||
|
||||
Assertions.assertDoesNotThrow(()->{
|
||||
@@ -50,7 +50,7 @@ class MenuModelTest {
|
||||
@Test
|
||||
void testCheckExternalLinkWhenFailed() {
|
||||
MenuModel externalWithoutHttpPrefix = new MenuModel();
|
||||
externalWithoutHttpPrefix.setIsExternal(true);
|
||||
// externalWithoutHttpPrefix.setIsExternal(true);
|
||||
externalWithoutHttpPrefix.setPath("www.baidu.com");
|
||||
|
||||
ApiException exception = assertThrows(ApiException.class, externalWithoutHttpPrefix::checkExternalLink);
|
||||
|
||||
Reference in New Issue
Block a user