2018-01-17 17:51:53 +08:00
|
|
|
|
package cn.keking.service.impl;
|
|
|
|
|
|
|
2018-03-25 13:26:51 +08:00
|
|
|
|
import cn.keking.model.FileAttribute;
|
2018-01-17 17:51:53 +08:00
|
|
|
|
import cn.keking.service.FilePreview;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Created by kl on 2018/1/17.
|
|
|
|
|
|
* Content :其他文件
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class OtherFilePreviewImpl implements FilePreview {
|
2020-12-27 14:47:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-01-17 17:51:53 +08:00
|
|
|
|
@Override
|
2019-06-17 14:21:16 +08:00
|
|
|
|
public String filePreviewHandle(String url, Model model, FileAttribute fileAttribute) {
|
2020-12-28 11:13:53 +08:00
|
|
|
|
return this.notSupportedFile(model, fileAttribute, "系统还不支持该格式文件的在线预览");
|
2020-12-27 14:47:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通用的预览失败,导向到不支持的文件响应页面
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 页面
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String notSupportedFile(Model model, FileAttribute fileAttribute, String errMsg) {
|
2020-12-28 11:13:53 +08:00
|
|
|
|
return this.notSupportedFile(model, fileAttribute.getSuffix(), errMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通用的预览失败,导向到不支持的文件响应页面
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 页面
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String notSupportedFile(Model model, String errMsg) {
|
|
|
|
|
|
return this.notSupportedFile(model, "未知", errMsg);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通用的预览失败,导向到不支持的文件响应页面
|
|
|
|
|
|
*
|
|
|
|
|
|
* @return 页面
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String notSupportedFile(Model model, String fileType, String errMsg) {
|
|
|
|
|
|
model.addAttribute("fileType", fileType);
|
2020-12-27 14:47:28 +08:00
|
|
|
|
model.addAttribute("msg", errMsg);
|
|
|
|
|
|
return NOT_SUPPORTED_FILE_PAGE;
|
2018-01-17 17:51:53 +08:00
|
|
|
|
}
|
2020-12-28 11:13:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-01-17 17:51:53 +08:00
|
|
|
|
}
|