Administrator
2021-08-19 6bd7ffcfcb0b5fb8dd1a5e95e78b07d9bb161f19
src/main/java/org/springblade/modules/resource/endpoint/OssEndpoint.java
@@ -34,7 +34,9 @@
import org.springblade.core.launch.constant.AppConstant;
import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.oss.model.OssFile;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.constant.RoleConstant;
@@ -209,7 +211,7 @@
            .headers(headers)
            .build());
      in.close();
      String urls = "http://192.168.0.109:9000/jfpt/" + newName;
      String urls = "http://192.168.0.109:9000/zhba/" + newName;
      return R.data(urls);
   }
@@ -235,10 +237,10 @@
    */
   @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 cardid) {
      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,cardid);
      bladeFile.setAttachId(attachId);
      return R.data(bladeFile);
   }
@@ -252,9 +254,9 @@
    */
   @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,String cardid) {
      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,cardid);
      bladeFile.setAttachId(attachId);
      return R.data(bladeFile);
   }
@@ -267,7 +269,8 @@
    * @param bladeFile 对象存储文件
    * @return attachId
    */
   private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type) throws Exception {
   private Long buildAttach(String fileName, Long fileSize, BladeFile bladeFile,String deptid,String type,Long noticeId,String cardid) throws Exception {
      //BladeUser user = AuthUtil.getUser();
      String fileExtension = FileUtil.getFileExtension(fileName);
      Attach attach = new Attach();
      attach.setDomain(bladeFile.getDomain());
@@ -277,9 +280,12 @@
      attach.setAttachSize(fileSize);
      attach.setExtension(fileExtension);
      attach.setDeptid(deptid);
      attach.setCardid(cardid);
      attach.setType(type);
      if (null!=noticeId){
         attach.setNoticeId(noticeId);
      }
      attachService.save(attach);
      arg.test01(arg.url+"/blade-resource/attach/save",attach);
      return attach.getId();
   }