feat: 完善系统配置审计通知功能并优化异常处理
- 新增异常处理体系(BaseException及其子类) - 优化密码、邮箱、用户名等基础类型 - 添加字典管理、登录日志、操作日志的E2E测试 - 完善API集成测试和安全测试 - 添加性能测试配置和脚本 - 优化OpenAPI配置和全局异常处理器
This commit is contained in:
+11
@@ -2,6 +2,8 @@ package cn.novalon.manage.file.handler;
|
||||
|
||||
import cn.novalon.manage.file.core.domain.SysFile;
|
||||
import cn.novalon.manage.file.core.service.ISysFileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.codec.multipart.FilePart;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -15,6 +17,7 @@ import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Component
|
||||
@Tag(name = "文件管理", description = "文件上传下载相关操作")
|
||||
public class SysFileHandler {
|
||||
|
||||
private final ISysFileService fileService;
|
||||
@@ -23,11 +26,13 @@ public class SysFileHandler {
|
||||
this.fileService = fileService;
|
||||
}
|
||||
|
||||
@Operation(summary = "获取所有文件", description = "获取系统中所有文件列表")
|
||||
public Mono<ServerResponse> getAllFiles(ServerRequest request) {
|
||||
Flux<SysFile> files = fileService.getAllFiles();
|
||||
return ServerResponse.ok().body(files, SysFile.class);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据ID获取文件", description = "根据文件ID获取文件详细信息")
|
||||
public Mono<ServerResponse> getFileById(ServerRequest request) {
|
||||
Long id = Long.parseLong(request.pathVariable("id"));
|
||||
return fileService.getFileById(id)
|
||||
@@ -35,6 +40,7 @@ public class SysFileHandler {
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "上传文件", description = "上传文件到系统")
|
||||
public Mono<ServerResponse> uploadFile(ServerRequest request) {
|
||||
String username = request.headers().firstHeader("X-Username");
|
||||
if (username == null) {
|
||||
@@ -60,6 +66,7 @@ public class SysFileHandler {
|
||||
.switchIfEmpty(ServerResponse.badRequest().bodyValue("No file data"));
|
||||
}
|
||||
|
||||
@Operation(summary = "下载文件", description = "根据文件ID下载文件")
|
||||
public Mono<ServerResponse> downloadFile(ServerRequest request) {
|
||||
Long id = Long.parseLong(request.pathVariable("id"));
|
||||
return fileService.getFileById(id)
|
||||
@@ -78,6 +85,7 @@ public class SysFileHandler {
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "根据文件名下载", description = "根据文件名下载文件")
|
||||
public Mono<ServerResponse> downloadFileByName(ServerRequest request) {
|
||||
String fileName = request.pathVariable("fileName");
|
||||
return fileService.getAllFiles()
|
||||
@@ -98,6 +106,7 @@ public class SysFileHandler {
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "预览文件", description = "根据文件ID预览文件")
|
||||
public Mono<ServerResponse> previewFile(ServerRequest request) {
|
||||
Long id = Long.parseLong(request.pathVariable("id"));
|
||||
return fileService.getFileById(id)
|
||||
@@ -115,6 +124,7 @@ public class SysFileHandler {
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "根据文件名预览", description = "根据文件名预览文件")
|
||||
public Mono<ServerResponse> previewFileByName(ServerRequest request) {
|
||||
String fileName = request.pathVariable("fileName");
|
||||
return fileService.getAllFiles()
|
||||
@@ -134,6 +144,7 @@ public class SysFileHandler {
|
||||
.switchIfEmpty(ServerResponse.notFound().build());
|
||||
}
|
||||
|
||||
@Operation(summary = "删除文件", description = "删除指定文件")
|
||||
public Mono<ServerResponse> deleteFile(ServerRequest request) {
|
||||
Long id = Long.parseLong(request.pathVariable("id"));
|
||||
return fileService.deleteFile(id)
|
||||
|
||||
Reference in New Issue
Block a user