| | |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach") |
| | | public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type) { |
| | | public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type,Long noticeId) { |
| | | String fileName = file.getOriginalFilename(); |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId); |
| | | bladeFile.setAttachId(attachId); |
| | | return R.data(bladeFile); |
| | | } |
| | |
| | | */ |
| | | @SneakyThrows |
| | | @PostMapping("/put-file-attach-by-name") |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type) { |
| | | public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type,Long noticeId) { |
| | | BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream()); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type); |
| | | Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type,noticeId); |
| | | bladeFile.setAttachId(attachId); |
| | | return R.data(bladeFile); |
| | | } |
| | |
| | | * @param bladeFile 对象存储文件 |
| | | * @return attachId |
| | | */ |
| | | private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type) { |
| | | private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type,Long noticeId) { |
| | | String fileExtension = FileUtil.getFileExtension(fileName); |
| | | Attach attach = new Attach(); |
| | | attach.setDomain(bladeFile.getDomain()); |
| | |
| | | attach.setExtension(fileExtension); |
| | | attach.setDeptid(deptid); |
| | | attach.setType(type); |
| | | if (null!=noticeId){ |
| | | attach.setNoticeId(noticeId); |
| | | } |
| | | attachService.save(attach); |
| | | return attach.getId(); |
| | | } |