标注结果和标注结果归档优化

This commit is contained in:
wh
2026-05-06 19:07:45 +08:00
parent 99ffa9d490
commit 9d8d06427c
20 changed files with 736 additions and 306 deletions

View File

@@ -68,23 +68,24 @@ public class SourceResourceController {
return Result.success();
}
@Operation(summary = "下载图片资源")
@Operation(summary = "下载资源")
@GetMapping("/{id}/download")
public ResponseEntity<byte[]> downloadImage(
public ResponseEntity<byte[]> downloadResource(
@Parameter(description = "资源ID", example = "191000000000000101")
@PathVariable Long id
) {
var currentUser = UserContext.requireUser();
byte[] imageData = sourceResourceService.downloadImage(currentUser, id);
byte[] resourceData = sourceResourceService.downloadResource(currentUser, id);
// 获取资源信息以确定Content-Type
SourceResource resource = sourceResourceService.getResourceEntity(id);
String contentType = sourceResourceService.getImageContentType(resource);
String contentType = sourceResourceService.getContentType(resource);
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_TYPE, contentType)
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + resource.getResourceName() + "\"")
.body(imageData);
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getResourceName() + "\"")
.header(HttpHeaders.CONTENT_LENGTH, String.valueOf(resource.getFileSize()))
.body(resourceData);
}
// 添加新接口