Skip to content
Merged
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
4f5d632
feat: add resource API
lu-yg Sep 5, 2025
df6ba91
fix: modify source API
lu-yg Sep 5, 2025
0fef229
fix: modify source API
lu-yg Sep 5, 2025
ab24c40
fix: modify source API
lu-yg Sep 5, 2025
787d1d1
fix: modify source API
lu-yg Sep 5, 2025
5fed78f
fix: modify source API
lu-yg Sep 5, 2025
d483f04
fix: modify source API
lu-yg Sep 5, 2025
72e9c67
fix: modify source API
lu-yg Sep 5, 2025
1fe61d5
fix: modify source API
lu-yg Sep 5, 2025
fd74ac8
fix: modify source API
lu-yg Sep 5, 2025
398e5c0
feat: add scheduled tasks
lu-yg Sep 9, 2025
0b8105c
fix: modify resource download
lu-yg Sep 9, 2025
6c9c7e4
fix: modify resource group update
lu-yg Sep 9, 2025
6178ed2
fix: modify resource group update
lu-yg Sep 9, 2025
3d723ae
fix: modify resource group update
lu-yg Sep 9, 2025
797045c
Merge branch 'opentiny:develop' into feat/resourceManagement
lu-yg Sep 10, 2025
3e2e616
fix: modify resource download
lu-yg Sep 10, 2025
603f65d
fix: modify block group
lu-yg Sep 15, 2025
f8d37c0
fix: modify AI chat
lu-yg Sep 16, 2025
e7c73d8
Merge branch 'opentiny:develop' into feat/resourceManagement
lu-yg Sep 16, 2025
6c4f3ea
fix: modify AI chat
lu-yg Sep 16, 2025
35a0b45
fix: modify AI chat
lu-yg Sep 16, 2025
4d7848b
fix: modify AI chat
lu-yg Sep 16, 2025
ad807d9
fix: modify AI chat
lu-yg Sep 16, 2025
53313bf
fix: modify AI chat
lu-yg Sep 16, 2025
ca4ff1b
fix: modify AI chat
lu-yg Sep 16, 2025
bff65fe
fix: modify AI chat
lu-yg Sep 16, 2025
f1fe5d0
Merge branch 'opentiny:develop' into feat/resourceManagement
lu-yg Sep 17, 2025
4eaee7a
fix: modify resource upload
lu-yg Sep 17, 2025
d211902
fix: modify resource upload
lu-yg Sep 17, 2025
28bef56
fix: modify resource upload
lu-yg Sep 17, 2025
a93100a
fix: modify resource upload
lu-yg Sep 17, 2025
1014efc
fix: modify resource upload
lu-yg Sep 17, 2025
68193ce
fix: modify resource upload
lu-yg Sep 17, 2025
64a7397
fix: modify resource upload
lu-yg Sep 17, 2025
363f728
fix: modify resource upload
lu-yg Sep 17, 2025
e0883be
fix: modify resource upload and download
lu-yg Sep 17, 2025
e6f23f6
Merge branch 'opentiny:develop' into feat/resourceManagement
lu-yg Sep 18, 2025
629eca3
fix: modify resource download
lu-yg Sep 18, 2025
786e039
fix: modify resource download
lu-yg Sep 18, 2025
3fde8ee
fix: modify resource download
lu-yg Sep 18, 2025
f04b791
fix: modify resource download
lu-yg Sep 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,34 +306,41 @@ public Result<Resource> detail(@PathVariable Integer id) {
})
@SystemControllerLog(description = "获取资源")
@GetMapping("/resource/download/{name}")
public void getResource(@PathVariable String name,
HttpServletResponse response) throws Exception {
if(name == null) {
throw new ServiceException(ExceptionEnum.CM009.getResultCode(),ExceptionEnum.CM009.getResultMsg());
public void getResource(@PathVariable String name, HttpServletResponse response) throws Exception {
// 参数校验
if (name == null || name.trim().isEmpty()) {
throw new ServiceException(ExceptionEnum.CM009.getResultCode(), ExceptionEnum.CM009.getResultMsg());
}

Resource resource = resourceService.queryResourceByName(name);
if(resource == null) {
throw new ServiceException(ExceptionEnum.CM009.getResultCode(),ExceptionEnum.CM009.getResultMsg());
if (resource == null) {
throw new ServiceException(ExceptionEnum.CM009.getResultCode(), ExceptionEnum.CM009.getResultMsg());
}

// 获取图片数据
String base64Data = Utils.isResource(name) ? resource.getResourceData() : resource.getThumbnailData();
if (base64Data == null || base64Data.trim().isEmpty()) {
throw new ServiceException(ExceptionEnum.CM009.getResultCode(), "资源数据为空");
}

String cleanBase64 = ImageThumbnailGenerator.extractCleanBase64(base64Data);
byte[] imageBytes = Base64.getDecoder().decode(cleanBase64);

// 设置响应头
String detectedType = ImageThumbnailGenerator.extractContentType(base64Data);
String encodedFileName = URLEncoder.encode(name, StandardCharsets.UTF_8).replace("+", "%20");

// URL编码文件名
String encodedFileName = URLEncoder.encode(name, StandardCharsets.UTF_8)
.replace("+", "%20");
// 设置必要的HTTP头
response.setContentType(detectedType);
response.setContentLength(imageBytes.length);

// 只使用 filename* 格式,避免中文字符直接出现在header中
response.setHeader("Content-Disposition", "inline; filename*=UTF-8''" + encodedFileName);
if(Utils.isDownload(name)){
response.setHeader("Content-Disposition", "attachment ; filename*=UTF-8''" + encodedFileName);
}
// 设置Content-Disposition
String contentDisposition = Utils.isDownload(name)
? "attachment; filename*=UTF-8''" + encodedFileName
: "inline; filename*=UTF-8''" + encodedFileName;
response.setHeader("Content-Disposition", contentDisposition);
// 写入响应体
try (OutputStream out = response.getOutputStream()) {
out.write(imageBytes);
out.flush();
}
}
}
Loading