| | |
| | | //文件后缀名 |
| | | String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); |
| | | //上传文件名 |
| | | String filename = format.format(new Date()) + suffix; |
| | | String filename = format.format(new Date()) + "_" + file.getOriginalFilename(); |
| | | //最终文件路径 |
| | | String filepath = path + "/" + filename; |
| | | //OSS文件存储路径 |
| | |
| | | |
| | | @RequestMapping(value = "/contract/download/auth") |
| | | @ManagerAuth(memo = "下载合同") |
| | | public ResponseEntity<InputStreamResource> download(@RequestParam("id") Integer id) { |
| | | public R download(@RequestParam("id") Integer id) { |
| | | Contract contract = contractService.selectById(id); |
| | | if (contract == null) { |
| | | return null; |
| | | return R.error(); |
| | | } |
| | | if (Cools.isEmpty(contract.getFilepath())) { |
| | | return null; |
| | | return R.error(); |
| | | } |
| | | |
| | | try { |
| | | return ossService.downloadFile(contract.getFilepath());//从OSS中下载文件 |
| | | } catch (Exception e) { |
| | | return null; |
| | | } |
| | | String download = ossService.download(contract.getFilepath());//获取OSS临时下载URL |
| | | return R.ok().add(download); |
| | | } |
| | | |
| | | @RequestMapping(value = "/contract/export/auth") |