|
|
@@ -1,5 +1,6 @@ |
|
|
|
package com.hz.pm.api.external; |
|
|
|
|
|
|
|
import cn.hutool.http.useragent.UserAgentUtil; |
|
|
|
import com.hz.pm.api.meeting.entity.config.WebProps; |
|
|
|
import com.ningdatech.basic.exception.BizException; |
|
|
|
import com.ningdatech.file.entity.File; |
|
|
@@ -10,6 +11,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 +28,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 +42,19 @@ 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(); |
|
|
|
log.info("serverName:{}", serverName); |
|
|
|
if (serverName.contains("weixin") || serverName.contains("10.54.38.13")) { |
|
|
|
// 浙政钉访问需要转换为互联网可访问的地址 |
|
|
|
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) { |
|
|
|