revert: remove download-origin config, return pathname only

This commit is contained in:
agentuser
2026-05-11 17:16:36 +08:00
parent 113facaeb2
commit a3100e61f4
2 changed files with 2 additions and 14 deletions
@@ -2,7 +2,6 @@ package com.gmp.mock.controller;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
@@ -27,13 +26,10 @@ public class DocxController {
private final DocxService docxService; private final DocxService docxService;
private final FileCacheService fileCache; private final FileCacheService fileCache;
private final String downloadOrigin;
public DocxController(DocxService docxService, FileCacheService fileCache, public DocxController(DocxService docxService, FileCacheService fileCache) {
@Value("${gmp.download-origin:}") String downloadOrigin) {
this.docxService = docxService; this.docxService = docxService;
this.fileCache = fileCache; this.fileCache = fileCache;
this.downloadOrigin = downloadOrigin;
} }
/** /**
@@ -55,10 +51,7 @@ public class DocxController {
) { ) {
CachedResult result = docxService.export(request.getExportId(), request.getBusinessData()); CachedResult result = docxService.export(request.getExportId(), request.getBusinessData());
// 构造下载 URL — 如果配置了 gmp.download-origin 则拼上 origin,否则只返回路径 String url = "/api/docx/download?id=" + result.key();
String url = downloadOrigin.isBlank()
? "/api/docx/download?id=" + result.key()
: downloadOrigin + "/api/docx/download?id=" + result.key();
ExportResultData data = new ExportResultData(url, result.fileName()); ExportResultData data = new ExportResultData(url, result.fileName());
return ResponseEntity.ok(ApiResponse.ok(data)); return ResponseEntity.ok(ApiResponse.ok(data));
-5
View File
@@ -4,8 +4,3 @@ server:
spring: spring:
application: application:
name: gmp-mock-service name: gmp-mock-service
# 文件下载 URL 前缀,为空则只返回路径(适用于同域访问)
# 生产环境设置完整 origin,例如: http://193.112.146.124:6666
gmp:
download-origin: http://193.112.146.124:6666