|
|
@@ -0,0 +1,40 @@ |
|
|
|
package com.hz.pm.api.external; |
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.ningdatech.file.entity.File; |
|
|
|
import com.ningdatech.file.service.FileService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
/** |
|
|
|
* <p> |
|
|
|
* FilePreviewClient |
|
|
|
* </p> |
|
|
|
* |
|
|
|
* @author WendyYang |
|
|
|
* @since 09:27 2024/3/18 |
|
|
|
*/ |
|
|
|
@Component |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class FilePreviewClient { |
|
|
|
|
|
|
|
@Value("${mh.file-preview.host:http://ztzz2.hzswb.cn/yl}") |
|
|
|
private String mhFilePreviewUrl; |
|
|
|
|
|
|
|
private final FileService fileService; |
|
|
|
|
|
|
|
//================================================================================================================== |
|
|
|
|
|
|
|
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) { |
|
|
|
File file = fileService.getById(fileId); |
|
|
|
if (file == null) { |
|
|
|
return StrUtil.EMPTY; |
|
|
|
} |
|
|
|
String fileUrl = fileService.findUrlByFile(file); |
|
|
|
return String.format(PREVIEW_PATH_FMT, mhFilePreviewUrl, fileUrl, file.getSuffix()); |
|
|
|
} |
|
|
|
|
|
|
|
} |