Archived
revert: remove download-origin config, return pathname only
This commit is contained in:
@@ -2,7 +2,6 @@ package com.gmp.mock.controller;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -27,13 +26,10 @@ public class DocxController {
|
||||
|
||||
private final DocxService docxService;
|
||||
private final FileCacheService fileCache;
|
||||
private final String downloadOrigin;
|
||||
|
||||
public DocxController(DocxService docxService, FileCacheService fileCache,
|
||||
@Value("${gmp.download-origin:}") String downloadOrigin) {
|
||||
public DocxController(DocxService docxService, FileCacheService fileCache) {
|
||||
this.docxService = docxService;
|
||||
this.fileCache = fileCache;
|
||||
this.downloadOrigin = downloadOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,10 +51,7 @@ public class DocxController {
|
||||
) {
|
||||
CachedResult result = docxService.export(request.getExportId(), request.getBusinessData());
|
||||
|
||||
// 构造下载 URL — 如果配置了 gmp.download-origin 则拼上 origin,否则只返回路径
|
||||
String url = downloadOrigin.isBlank()
|
||||
? "/api/docx/download?id=" + result.key()
|
||||
: downloadOrigin + "/api/docx/download?id=" + result.key();
|
||||
String url = "/api/docx/download?id=" + result.key();
|
||||
|
||||
ExportResultData data = new ExportResultData(url, result.fileName());
|
||||
return ResponseEntity.ok(ApiResponse.ok(data));
|
||||
|
||||
@@ -4,8 +4,3 @@ server:
|
||||
spring:
|
||||
application:
|
||||
name: gmp-mock-service
|
||||
|
||||
# 文件下载 URL 前缀,为空则只返回路径(适用于同域访问)
|
||||
# 生产环境设置完整 origin,例如: http://193.112.146.124:6666
|
||||
gmp:
|
||||
download-origin: http://193.112.146.124:6666
|
||||
|
||||
Reference in New Issue
Block a user