* tif图片预览,根据反馈的意见,已经全部修改

This commit is contained in:
zhangzhen1979
2021-12-09 19:10:23 +08:00
committed by kl
parent 6387ac21c9
commit d424de5e9a
6 changed files with 31 additions and 11 deletions

View File

@ -14,6 +14,7 @@ public class FileAttribute {
private String url;
private String fileKey;
private String officePreviewType = ConfigConstants.getOfficePreviewType();
private String previewType;
public FileAttribute() {
}
@ -33,6 +34,15 @@ public class FileAttribute {
this.officePreviewType = officePreviewType;
}
public FileAttribute(FileType type, String suffix, String name, String url, String officePreviewType, String previewType) {
this.type = type;
this.suffix = suffix;
this.name = name;
this.url = url;
this.officePreviewType = officePreviewType;
this.previewType = previewType;
}
public String getFileKey() {
return fileKey;
}
@ -80,4 +90,13 @@ public class FileAttribute {
public void setUrl(String url) {
this.url = url;
}
public String getPreviewType() {
return previewType;
}
public void setPreviewType(String previewType) {
this.previewType = previewType;
}
}

View File

@ -284,6 +284,11 @@ public class FileHandlerService {
if (StringUtils.hasText(fileKey)) {
attribute.setFileKey(fileKey);
}
String previewType = req.getParameter("previewType");
if (StringUtils.hasText(previewType)) {
attribute.setPreviewType(previewType);
}
}
return attribute;
}

View File

@ -39,9 +39,11 @@ public class TiffFilePreviewImpl implements FilePreview {
@Override
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
String tifPreviewType = ConfigConstants.getTifPreviewType();
String priveiwType = String.valueOf(model.getAttribute("previewType"));
String previewType = fileAttribute.getPreviewType();
if (StringUtils.hasText(previewType)) {
tifPreviewType = previewType;
}
if("tif".equalsIgnoreCase(tifPreviewType)){
@ -77,7 +79,7 @@ public class TiffFilePreviewImpl implements FilePreview {
}
String baseUrl = BaseUrlFilter.getBaseUrl();
if("pdf".equalsIgnoreCase(tifPreviewType) && !"image".equalsIgnoreCase(priveiwType)){
if("pdf".equalsIgnoreCase(tifPreviewType)){
File filePdf = ConvertPicUtil.convertJpg2Pdf(fileDir + uuid + ".jpg", fileDir + uuid + ".pdf");
if(filePdf.exists()){
String pdfUrl = baseUrl + uuid + ".pdf";

View File

@ -70,10 +70,6 @@ public class OnlinePreviewController {
}
FileAttribute fileAttribute = fileHandlerService.getFileAttribute(fileUrl, req);
model.addAttribute("file", fileAttribute);
String previewType = req.getParameter("previewType");
model.addAttribute("previewType", previewType);
FilePreview filePreview = previewFactory.get(fileAttribute);
logger.info("预览文件url{}previewType{}", fileUrl, fileAttribute.getType());
return filePreview.filePreviewHandle(fileUrl, model, fileAttribute);