Browse Source

modify:

1. 移动端预览修改;
tags/24080901
WendyYang 5 months ago
parent
commit
fd92d4abcb
5 changed files with 34 additions and 11 deletions
  1. +17
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java
  2. +3
    -2
      hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java
  3. +9
    -0
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java
  4. +1
    -1
      hz-pm-api/src/main/resources/application-dev.yml
  5. +4
    -2
      hz-pm-api/src/main/resources/application-prod.yml

+ 17
- 6
hz-pm-api/src/main/java/com/hz/pm/api/external/FilePreviewClient.java View File

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


+ 3
- 2
hz-pm-api/src/main/java/com/hz/pm/api/external/controller/FilePreviewController.java View File

@@ -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("文件下载(不鉴权)")


+ 9
- 0
hz-pm-api/src/main/java/com/hz/pm/api/meeting/entity/config/WebProps.java View File

@@ -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;
}

} }

+ 1
- 1
hz-pm-api/src/main/resources/application-dev.yml View File

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


+ 4
- 2
hz-pm-api/src/main/resources/application-prod.yml View File

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


Loading…
Cancel
Save