tangzy
2021-07-14 5fb38e71cc5ab8eee8e7f489c4476d59104f07df
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -171,10 +171,10 @@
    */
   @SneakyThrows
   @PostMapping("/put-file-attach")
   public R<BladeFile> putFileAttach(@RequestParam MultipartFile file) {
   public R<BladeFile> putFileAttach(@RequestParam MultipartFile file,String deptid,String type) {
      String fileName = file.getOriginalFilename();
      BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
      Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
      Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
      bladeFile.setAttachId(attachId);
      return R.data(bladeFile);
   }
@@ -188,9 +188,9 @@
    */
   @SneakyThrows
   @PostMapping("/put-file-attach-by-name")
   public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file) {
   public R<BladeFile> putFileAttach(@RequestParam String fileName, @RequestParam MultipartFile file,String deptid,String type) {
      BladeFile bladeFile = ossBuilder.template().putFile(fileName, file.getInputStream());
      Long attachId = buildAttach(fileName, file.getSize(), bladeFile);
      Long attachId = buildAttach(fileName, file.getSize(), bladeFile,deptid,type);
      bladeFile.setAttachId(attachId);
      return R.data(bladeFile);
   }
@@ -203,7 +203,7 @@
    * @param bladeFile 对象存储文件
    * @return attachId
    */
   private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile) {
   private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type) {
      String fileExtension = FileUtil.getFileExtension(fileName);
      Attach attach = new Attach();
      attach.setDomain(bladeFile.getDomain());
@@ -212,6 +212,8 @@
      attach.setOriginalName(bladeFile.getOriginalName());
      attach.setAttachSize(fileSize);
      attach.setExtension(fileExtension);
      attach.setDeptid(deptid);
      attach.setType(type);
      attachService.save(attach);
      return attach.getId();
   }