feat(特色专区-资源支持上传至Nexus): 优化Nexus文件下载逻辑

通过重定向到Nexus下载文件时,也需要更新文件下载次数
This commit is contained in:
欧涛 2026-01-15 16:15:35 +08:00
parent a8bfda01e4
commit 54b897bf05
1 changed files with 8 additions and 0 deletions

View File

@ -321,6 +321,14 @@ public class SysFileInfoServiceImpl implements ISysFileInfoService {
}
private void fileDownloadNexus(SysFileInfo sysFileInfo, HttpServletResponse response) {
// 更新下载次数
int downloadCount = 1;
if (sysFileInfo.getDownloadCount() != null) {
downloadCount = sysFileInfo.getDownloadCount() + 1;
}
sysFileInfo.setDownloadCount(downloadCount);
updateSysFileInfo(sysFileInfo);
// 重定向Nexus下载地址
response.setStatus(302);
String nexusUrl=NexusRequestUrl.GET_NEXUS_FILE_URL(nexusRequestHelper.nexusUrl, fileUploadNexusRepo, ServletUtils.urlEncodeExcludeSlashesApplyDuplicate(sysFileInfo.getFilePath()));
response.setHeader("Location", nexusUrl);