|
|
@@ -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) { |
|
|
|