diff --git a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java index ed598bf8e..5c713d793 100644 --- a/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java +++ b/jero-boot/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java @@ -180,8 +180,82 @@ public class CommonController { * @param request * @param response */ - @GetMapping(value = "/download/{id}") - public void view(@PathVariable String id,HttpServletRequest request, HttpServletResponse response) { +// @GetMapping(value = "/download/{id}") +// public void view(@PathVariable String id,HttpServletRequest request, HttpServletResponse response) { +// // 查询数据表数据是否存在 +// LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); +// queryWrapper.eq(OSSFile::getId,id); +// OSSFile ossFile = ossFileService.getOne(queryWrapper); +// if( null == ossFile){ +// throw new JeroBootException("文件不存在.."); +// } +// String fileUrl = ossFile.getUrl(); +// InputStream inputStream = null; +// OutputStream outputStream = null; +// try { +// String fileName = ""; +// if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ +// //本地下载 +// String filePath = uploadpath + File.separator + fileUrl; +// File file = new File(filePath); +// if(!file.exists()){ +// response.setStatus(404); +// throw new RuntimeException("文件不存在.."); +// } +// // 文件名称 +// fileName = file.getName(); +// inputStream = new BufferedInputStream(new FileInputStream(filePath)); +// }else if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ +// // minio 下载 +// // 通过MinioUtil查询时 只需要桶后面的路径 +// String minioUrl = MinioUtil.getMinioUrl(); +// // Linux/unix 系统下文件路径分隔符为"/" 获取minio与存储桶的路径 +// minioUrl = minioUrl + MinioUtil.getBucketName() + "/"; +// String url = fileUrl.replace(minioUrl, ""); +// // 文件名称 +// fileName = ossFile.getFileName(); +// inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url); +// } +// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); +// response.setContentType("application/force-download");// 设置强制下载不打开 +// outputStream = response.getOutputStream(); +// byte[] buf = new byte[1024]; +// int len; +// while ((len = inputStream.read(buf)) > 0) { +// outputStream.write(buf, 0, len); +// } +// response.flushBuffer(); +// } catch (IOException e) { +// log.error("预览文件失败" + e.getMessage()); +// response.setStatus(404); +// e.printStackTrace(); +// } finally { +// if (inputStream != null) { +// try { +// inputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// if (outputStream != null) { +// try { +// outputStream.close(); +// } catch (IOException e) { +// log.error(e.getMessage(), e); +// } +// } +// } +// +// } + /** + * 下载文件 + * + * @param id 传入文件id + * @param request + * @param response + */ + @GetMapping(value = "/download") + public void downLoad(String id,HttpServletRequest request, HttpServletResponse response) { // 查询数据表数据是否存在 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(OSSFile::getId,id); @@ -189,33 +263,20 @@ public class CommonController { if( null == ossFile){ throw new JeroBootException("文件不存在.."); } - String fileUrl = ossFile.getUrl(); InputStream inputStream = null; OutputStream outputStream = null; try { String fileName = ""; - if(CommonConstant.UPLOAD_TYPE_LOCAL.equals(uploadType)){ - //本地下载 - String filePath = uploadpath + File.separator + fileUrl; - File file = new File(filePath); - if(!file.exists()){ - response.setStatus(404); - throw new RuntimeException("文件不存在.."); - } - // 文件名称 - fileName = file.getName(); - inputStream = new BufferedInputStream(new FileInputStream(filePath)); - }else if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){ - // minio 下载 - // 通过MinioUtil查询时 只需要桶后面的路径 - String minioUrl = MinioUtil.getMinioUrl(); - // Linux/unix 系统下文件路径分隔符为"/" 获取minio与存储桶的路径 - minioUrl = minioUrl + MinioUtil.getBucketName() + "/"; - String url = fileUrl.replace(minioUrl, ""); - // 文件名称 - fileName = ossFile.getFileName(); - inputStream = MinioUtil.getMinioFile(MinioUtil.getBucketName(), url); + //本地下载 + String filePath = ossFile.getUrl(); + File file = new File(filePath); + if(!file.exists()){ + response.setStatus(404); + throw new RuntimeException("文件不存在.."); } + // 文件名称 + fileName = file.getName(); + inputStream = new BufferedInputStream(new FileInputStream(filePath)); response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); response.setContentType("application/force-download");// 设置强制下载不打开 outputStream = response.getOutputStream(); @@ -226,7 +287,7 @@ public class CommonController { } response.flushBuffer(); } catch (IOException e) { - log.error("预览文件失败" + e.getMessage()); + log.error("文件下载失败" + e.getMessage()); response.setStatus(404); e.printStackTrace(); } finally { diff --git a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/entity/BussDocumentLibraryEO.java b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/entity/BussDocumentLibraryEO.java index 311cf269e..83a595e59 100644 --- a/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/entity/BussDocumentLibraryEO.java +++ b/jero-boot/jero-boot-modules/src/main/java/com/jero/modules/document/entity/BussDocumentLibraryEO.java @@ -185,9 +185,4 @@ public class BussDocumentLibraryEO implements Serializable { @ApiModelProperty(value = "预警标识") private java.lang.String warnFlag; - /**订阅标志*/ - @Excel(name = "订阅标志", width = 15) - @ApiModelProperty(value = "订阅标志") - private java.lang.String readFlag; - }