From fd92d4abcba85e6d2f7a128dcab1d633475caaee Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 16 Jul 2024 17:13:21 +0800 Subject: [PATCH] =?UTF-8?q?modify:=201.=20=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E9=A2=84=E8=A7=88=E4=BF=AE=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hz/pm/api/external/FilePreviewClient.java | 23 ++++++++++++++++------ .../external/controller/FilePreviewController.java | 5 +++-- .../hz/pm/api/meeting/entity/config/WebProps.java | 9 +++++++++ hz-pm-api/src/main/resources/application-dev.yml | 2 +- hz-pm-api/src/main/resources/application-prod.yml | 6 ++++-- 5 files changed, 34 insertions(+), 11 deletions(-) diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java index 4cca3dd..f886a65 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java @@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** @@ -26,8 +27,11 @@ public class FilePreviewClient { private static final Logger log = LoggerFactory.getLogger(FilePreviewClient.class); - @Value("${mh.file-preview.host}") - private String mhFilePreviewUrl; + @Value("${mh.file-preview.public-host:}") + private String mhFilePreviewPublicUrl; + + @Value("${mh.file-preview.private-host:}") + private String mhFilePreviewPrivateUrl; private final FileService fileService; @@ -37,10 +41,17 @@ public class FilePreviewClient { private static final String PREVIEW_PATH_FMT = "%s/public/risen/core/resrc/view/pdf_view.html.do?strMap.remote_url=%s&strMap.ext=%s"; - public String getFilePreviewUrl(Long fileId) { - String fileDownUrl = WebProps.apiUrl + FILE_DOWN_NO_AUTH_URL + fileId; - File file = fileService.getById(fileId); - return String.format(PREVIEW_PATH_FMT, mhFilePreviewUrl, fileDownUrl, file.getSuffix()); + public String getFilePreviewUrl(Long fileId, HttpServletRequest request) { + String serverName = request.getServerName(); + if (serverName.contains("weixin")) { + String fileDownUrl = WebProps.zzdApiUrl + FILE_DOWN_NO_AUTH_URL + fileId; + File file = fileService.getById(fileId); + return String.format(PREVIEW_PATH_FMT, mhFilePreviewPublicUrl, fileDownUrl, file.getSuffix()); + } else { + String fileDownUrl = WebProps.apiUrl + FILE_DOWN_NO_AUTH_URL + fileId; + File file = fileService.getById(fileId); + return String.format(PREVIEW_PATH_FMT, mhFilePreviewPrivateUrl, fileDownUrl, file.getSuffix()); + } } public void downloadFile(Long fileId, HttpServletResponse response) { diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java b/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java index fa20386..a3d9883 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java @@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** @@ -29,8 +30,8 @@ public class FilePreviewController { @ApiOperation("获取文件的预览地址") @GetMapping("/getFilePreviewUrl/{fileId}") - public String getFilePreviewUrl(@PathVariable Long fileId) { - return filePreviewClient.getFilePreviewUrl(fileId); + public String getFilePreviewUrl(@PathVariable Long fileId, HttpServletRequest request) { + return filePreviewClient.getFilePreviewUrl(fileId, request); } @ApiOperation("文件下载(不鉴权)") diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java index 22275d1..b8f3553 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java @@ -20,6 +20,10 @@ public class WebProps { public static String apiUrl; + public static String zzdApiUrl; + + + @Value("${web.login.url:}") private void setLoginUrl(String url) { loginUrl = url; @@ -30,4 +34,9 @@ public class WebProps { apiUrl = url; } + @Value("${web.zzd-api.url:}") + private void setZzdApiUrl(String url) { + zzdApiUrl = url; + } + } diff --git a/hz-pm-api/src/main/resources/application-dev.yml b/hz-pm-api/src/main/resources/application-dev.yml index 05403fe..13e3f26 100644 --- a/hz-pm-api/src/main/resources/application-dev.yml +++ b/hz-pm-api/src/main/resources/application-dev.yml @@ -189,7 +189,7 @@ mh: detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin file-preview: - host: http://ztzz2.hzswb.cn/yl + public-host: http://ztzz2.hzswb.cn/yl auth-code: secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 diff --git a/hz-pm-api/src/main/resources/application-prod.yml b/hz-pm-api/src/main/resources/application-prod.yml index 6e400f2..aa17e27 100644 --- a/hz-pm-api/src/main/resources/application-prod.yml +++ b/hz-pm-api/src/main/resources/application-prod.yml @@ -182,6 +182,8 @@ web: url: https://hzszxc.hzswb.cn:8443/project api: url: https://hzszxc.hzswb.cn:8443/hzpm + zzd-api: + url: https://weixin.hzszxc.hzswb.cn:8143/hzpm mh: sso: @@ -199,8 +201,8 @@ mh: purchase-notice: open: true file-preview: - # host: http://ztzz2.hzswb.cn/yl - host: http://172.18.43.208/yl + public-host: http://ztzz2.hzswb.cn/yl + private-host: http://172.18.43.208/yl sms-send: host: http://10.54.38.13:8081/mh-gateway/auth-single