feat: 添加异常日志功能并优化UI样式
refactor: 重构后端查询逻辑和API响应处理 fix: 修复用户角色更新和文件上传问题 test: 添加前端性能测试脚本和E2E测试用例 chore: 更新依赖版本和配置文件 docs: 添加环境检查脚本和测试文档 style: 统一表格标签样式和路由命名 perf: 优化前端页面加载速度和响应时间
This commit is contained in:
+3
-3
@@ -7,7 +7,7 @@ public class SysFile {
|
||||
private Long id;
|
||||
private String fileName;
|
||||
private String filePath;
|
||||
private String fileSize;
|
||||
private Long fileSize;
|
||||
private String fileType;
|
||||
private String storageType;
|
||||
private String createBy;
|
||||
@@ -21,8 +21,8 @@ public class SysFile {
|
||||
public void setFileName(String fileName) { this.fileName = fileName; }
|
||||
public String getFilePath() { return filePath; }
|
||||
public void setFilePath(String filePath) { this.filePath = filePath; }
|
||||
public String getFileSize() { return fileSize; }
|
||||
public void setFileSize(String fileSize) { this.fileSize = fileSize; }
|
||||
public Long getFileSize() { return fileSize; }
|
||||
public void setFileSize(Long fileSize) { this.fileSize = fileSize; }
|
||||
public String getFileType() { return fileType; }
|
||||
public void setFileType(String fileType) { this.fileType = fileType; }
|
||||
public String getStorageType() { return storageType; }
|
||||
|
||||
+8
-4
@@ -3,6 +3,7 @@ package cn.novalon.manage.file.core.service.impl;
|
||||
import cn.novalon.manage.file.core.domain.SysFile;
|
||||
import cn.novalon.manage.file.core.repository.ISysFileRepository;
|
||||
import cn.novalon.manage.file.core.service.ISysFileService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.codec.multipart.FilePart;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.publisher.Flux;
|
||||
@@ -19,10 +20,13 @@ import java.util.UUID;
|
||||
public class SysFileServiceImpl implements ISysFileService {
|
||||
|
||||
private final ISysFileRepository fileRepository;
|
||||
private final String uploadDir = "/app/uploads";
|
||||
private final String uploadDir;
|
||||
|
||||
public SysFileServiceImpl(ISysFileRepository fileRepository) {
|
||||
public SysFileServiceImpl(
|
||||
ISysFileRepository fileRepository,
|
||||
@Value("${file.upload.dir:/tmp/uploads}") String uploadDir) {
|
||||
this.fileRepository = fileRepository;
|
||||
this.uploadDir = uploadDir;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,7 +72,7 @@ public class SysFileServiceImpl implements ISysFileService {
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setFileName(originalFilename);
|
||||
sysFile.setFilePath(filePath.toString());
|
||||
sysFile.setFileSize(String.valueOf(fileSize));
|
||||
sysFile.setFileSize(fileSize);
|
||||
sysFile.setFileType(contentType);
|
||||
sysFile.setStorageType("LOCAL");
|
||||
sysFile.setCreateBy(username);
|
||||
@@ -87,7 +91,7 @@ public class SysFileServiceImpl implements ISysFileService {
|
||||
.flatMap(file -> {
|
||||
try {
|
||||
Path filePath = Paths.get(file.getFilePath());
|
||||
byte[] fileContent = Files.readAllBytes(filePath);
|
||||
Files.readAllBytes(filePath);
|
||||
return Mono.empty();
|
||||
} catch (IOException e) {
|
||||
return Mono.error(e);
|
||||
|
||||
+3
-2
@@ -2,6 +2,7 @@ package cn.novalon.manage.file.handler;
|
||||
|
||||
import cn.novalon.manage.file.core.domain.SysFile;
|
||||
import cn.novalon.manage.file.core.service.ISysFileService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.codec.multipart.FilePart;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||
@@ -54,7 +55,7 @@ public class SysFileHandler {
|
||||
|
||||
final FilePart filePart = (FilePart) part;
|
||||
return fileService.uploadFile(filePart, finalUsername)
|
||||
.flatMap(file -> ServerResponse.ok().bodyValue(file));
|
||||
.flatMap(file -> ServerResponse.status(HttpStatus.CREATED).bodyValue(file));
|
||||
})
|
||||
.switchIfEmpty(ServerResponse.badRequest().bodyValue("No file data"));
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public class SysFileHandler {
|
||||
public Mono<ServerResponse> deleteFile(ServerRequest request) {
|
||||
Long id = Long.parseLong(request.pathVariable("id"));
|
||||
return fileService.deleteFile(id)
|
||||
.then(ServerResponse.ok().build())
|
||||
.then(ServerResponse.noContent().build())
|
||||
.onErrorResume(e -> ServerResponse.badRequest().bodyValue(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -26,13 +26,13 @@ class SysFileServiceTest {
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
fileService = new SysFileServiceImpl(fileRepository);
|
||||
fileService = new SysFileServiceImpl(fileRepository, "/tmp/uploads");
|
||||
testFile = new SysFile();
|
||||
testFile.setId(1L);
|
||||
testFile.setFileName("test.txt");
|
||||
testFile.setFilePath("/app/uploads/test.txt");
|
||||
testFile.setFilePath("/tmp/uploads/test.txt");
|
||||
testFile.setFileType("text/plain");
|
||||
testFile.setFileSize("1024");
|
||||
testFile.setFileSize(1024L);
|
||||
testFile.setCreateBy("testuser");
|
||||
testFile.setStorageType("LOCAL");
|
||||
}
|
||||
|
||||
+4
-4
@@ -33,9 +33,9 @@ class SysFileHandlerTest {
|
||||
testFile = new SysFile();
|
||||
testFile.setId(1L);
|
||||
testFile.setFileName("test.txt");
|
||||
testFile.setFilePath("/app/uploads/test.txt");
|
||||
testFile.setFilePath("/tmp/uploads/test.txt");
|
||||
testFile.setFileType("text/plain");
|
||||
testFile.setFileSize("1024");
|
||||
testFile.setFileSize(1024L);
|
||||
testFile.setCreateBy("testuser");
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class SysFileHandlerTest {
|
||||
|
||||
StepVerifier.create(response)
|
||||
.expectNextMatches(serverResponse ->
|
||||
serverResponse.statusCode() == HttpStatus.OK)
|
||||
serverResponse.statusCode() == HttpStatus.NO_CONTENT)
|
||||
.verifyComplete();
|
||||
|
||||
verify(fileService).deleteFile(1L);
|
||||
@@ -116,7 +116,7 @@ class SysFileHandlerTest {
|
||||
|
||||
StepVerifier.create(response)
|
||||
.expectNextMatches(serverResponse ->
|
||||
serverResponse.statusCode() == HttpStatus.OK)
|
||||
serverResponse.statusCode() == HttpStatus.NO_CONTENT)
|
||||
.verifyComplete();
|
||||
|
||||
verify(fileService).deleteFile(999L);
|
||||
|
||||
Reference in New Issue
Block a user