@@ -10,6 +10,7 @@ import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
/** | /** | ||||
@@ -26,8 +27,11 @@ public class FilePreviewClient { | |||||
private static final Logger log = LoggerFactory.getLogger(FilePreviewClient.class); | 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; | 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"; | 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) { | public void downloadFile(Long fileId, HttpServletResponse response) { | ||||
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
/** | /** | ||||
@@ -29,8 +30,8 @@ public class FilePreviewController { | |||||
@ApiOperation("获取文件的预览地址") | @ApiOperation("获取文件的预览地址") | ||||
@GetMapping("/getFilePreviewUrl/{fileId}") | @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("文件下载(不鉴权)") | @ApiOperation("文件下载(不鉴权)") | ||||
@@ -20,6 +20,10 @@ public class WebProps { | |||||
public static String apiUrl; | public static String apiUrl; | ||||
public static String zzdApiUrl; | |||||
@Value("${web.login.url:}") | @Value("${web.login.url:}") | ||||
private void setLoginUrl(String url) { | private void setLoginUrl(String url) { | ||||
loginUrl = url; | loginUrl = url; | ||||
@@ -30,4 +34,9 @@ public class WebProps { | |||||
apiUrl = url; | apiUrl = url; | ||||
} | } | ||||
@Value("${web.zzd-api.url:}") | |||||
private void setZzdApiUrl(String url) { | |||||
zzdApiUrl = url; | |||||
} | |||||
} | } |
@@ -189,7 +189,7 @@ mh: | |||||
detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | 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 | upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin | ||||
file-preview: | file-preview: | ||||
host: http://ztzz2.hzswb.cn/yl | |||||
public-host: http://ztzz2.hzswb.cn/yl | |||||
auth-code: | auth-code: | ||||
secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | ||||
@@ -182,6 +182,8 @@ web: | |||||
url: https://hzszxc.hzswb.cn:8443/project | url: https://hzszxc.hzswb.cn:8443/project | ||||
api: | api: | ||||
url: https://hzszxc.hzswb.cn:8443/hzpm | url: https://hzszxc.hzswb.cn:8443/hzpm | ||||
zzd-api: | |||||
url: https://weixin.hzszxc.hzswb.cn:8143/hzpm | |||||
mh: | mh: | ||||
sso: | sso: | ||||
@@ -199,8 +201,8 @@ mh: | |||||
purchase-notice: | purchase-notice: | ||||
open: true | open: true | ||||
file-preview: | 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: | sms-send: | ||||
host: http://10.54.38.13:8081/mh-gateway/auth-single | host: http://10.54.38.13:8081/mh-gateway/auth-single | ||||