| | |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | /** |
| | | * @title: 附件信息表接口api-web端 |
| | |
| | | |
| | | /** |
| | | * 页面附件上传-文件流方式 |
| | | * @url {ctx}/api/web/fileInfo/upload?mainId=&ownerId=&ownerType= |
| | | * |
| | | * @param mainId 所属业务主体编号 |
| | | * @param ownerId 所属业务编号 |
| | | * @param ownerType 所属业务类型 |
| | | * @param request 请求头 |
| | | * @return Object |
| | | * @url {ctx}/api/web/fileInfo/upload?mainId=&ownerId=&ownerType= |
| | | */ |
| | | @PostMapping("/upload") |
| | | public Object upload(@RequestParam(value = "mainId") String mainId, |
| | |
| | | |
| | | /** |
| | | * 在线查附件-文件流方式 |
| | | * @url {ctx}/api/web/fileInfo/show/{id} |
| | | * |
| | | * @param id 附件编号 |
| | | * @param response 响应头 |
| | | * @throws Exception |
| | | * @url {ctx}/api/web/fileInfo/show/{id} |
| | | */ |
| | | @GetMapping("/show/{id}") |
| | | public void show(@PathVariable(value = "id") String id, HttpServletResponse response){ |
| | |
| | | |
| | | /** |
| | | * 在线下载附件-文件流方式 |
| | | * @url {ctx}/api/web/fileInfo/down/{id} |
| | | * |
| | | * @param id 附件编号 |
| | | * @param response 响应头 |
| | | * @url {ctx}/api/web/fileInfo/down/{id} |
| | | */ |
| | | @GetMapping("/down/{id}") |
| | | public void down(@PathVariable(value = "id") String id, HttpServletResponse response){ |
| | |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/down/batch") |
| | | public void downBatch(@RequestParam(value = "ids") String ids, HttpServletResponse response) { |
| | | try { |
| | | String[] id = ids.split(","); |
| | | // 设置ZIP文件响应类型 |
| | | response.setContentType("application/zip"); |
| | | response.setHeader("Content-Disposition", "attachment;filename=files.zip"); |
| | | |
| | | ZipOutputStream zipOutputStream = new ZipOutputStream(response.getOutputStream()); |
| | | for (String s : id) { |
| | | FileInfo fileInfo = service.getById(s); |
| | | FtpUtils ftpUtil = new FtpUtils(); |
| | | InputStream inputStream = ftpUtil.retrieveFileStream(fileInfo.getFullPath()); |
| | | |
| | | // 每个文件写入到ZIP包中 |
| | | zipOutputStream.putNextEntry(new ZipEntry(fileInfo.getName() + BaseConsts.DOT + fileInfo.getSuffix())); |
| | | IOUtils.copy(inputStream, zipOutputStream); |
| | | zipOutputStream.closeEntry(); |
| | | IOUtils.closeQuietly(inputStream); |
| | | } |
| | | IOUtils.closeQuietly(zipOutputStream); |
| | | } catch (Exception e) { |
| | | log.error("controller接口[FileInfoWebController.down]请求失败,异常信息:" + e, e); |
| | | throw new ClientException("FileInfoWebController.down", e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * ocr识别文字 |
| | | * @url {ctx}/api/web/fileInfo/recognitionText?ownerId=&ownerType= |
| | | * |
| | | * @param request |
| | | * @return Object |
| | | * @url {ctx}/api/web/fileInfo/recognitionText?ownerId=&ownerType= |
| | | */ |
| | | @PostMapping(value = "/recognitionText") |
| | | public Object recognitionText(MultipartHttpServletRequest request){ |
| | |
| | | |
| | | /** |
| | | * 查看附件组件-分类查询附件 |
| | | * @url {ctx}/api/web/fileInfo/listFileByCat |
| | | * |
| | | * @param mainId 所属业务主体编号 |
| | | * @return Object |
| | | * @url {ctx}/api/web/fileInfo/listFileByCat |
| | | */ |
| | | @GetMapping("/listFileByCat") |
| | | public Object listFileByCat(@RequestParam(value = "mainId") String mainId, @CurrentUser String userId) { |
| | |
| | | |
| | | /** |
| | | * 删除附件 |
| | | * @url {ctx}/api/web/fileInfo/deleteFileById?id= |
| | | * @param id 附件编号 |
| | | * |
| | | * @param ids 附件编号集合 |
| | | * @return Object |
| | | * @url {ctx}/api/web/fileInfo/deleteFileById?id= |
| | | */ |
| | | @GetMapping("/deleteFileById") |
| | | public Object deleteFileById(@RequestParam(value = "id") String id) { |
| | | @DeleteMapping("/deleteFileById") |
| | | public Object deleteFileById(@RequestParam(value = "ids") String ids) { |
| | | try { |
| | | service.deleteFileById(id); |
| | | String[] id = ids.split(","); |
| | | for (String s : id) { |
| | | service.deleteFileById(s); |
| | | } |
| | | return ReturnSucUtils.getRepInfo(); |
| | | } catch (Exception e) { |
| | | return ReturnFailUtils.getRepInfo(); |
| | |
| | | |
| | | /** |
| | | * 根据多个所属编号查询附件并根据先根据ownerId再根据附件类型分组 |
| | | * @url {ctx}/api/web/fileInfo/listIdTypeInfo |
| | | * |
| | | * @return Object |
| | | * @url {ctx}/api/web/fileInfo/listIdTypeInfo |
| | | */ |
| | | @PostMapping("/listIdTypeInfo") |
| | | public Object listIdTypeInfo(@RequestBody IdFileDTO idFileDTO) { |