Просмотр исходного кода

Merge branch 'release-v4.13.4' into test

# Conflicts:
#	src/main/java/com/fdkankan/scene/service/impl/BoxModelServiceImpl.java
dengsixing 7 месяцев назад
Родитель
Сommit
d4be428b9c

+ 24 - 7
src/main/java/com/fdkankan/scene/service/impl/BoxModelServiceImpl.java

@@ -45,6 +45,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
  * TODO
@@ -57,7 +59,7 @@ import org.springframework.web.multipart.MultipartFile;
 @Service
 public class BoxModelServiceImpl implements IBoxModelService {
 
-    @Autowired
+    @Resource
     private FYunFileServiceInterface fYunFileService;
     @Autowired
     private IScenePlusService scenePlusService;
@@ -84,9 +86,10 @@ public class BoxModelServiceImpl implements IBoxModelService {
 //            throw new BusinessException(ErrorCode.FAILURE_CODE_7023, "5M");
 //        }
         String path = String.format(ConstantFilePath.SCENE_USER_PATH_V4, num) + "boxModel/" + sid + "/";
-        String zipPath = path + file.getOriginalFilename();
-        String srcPath = path + "data/";
-        String glbPath = path + sid + ".glb";
+        try {
+            String zipPath = path + file.getOriginalFilename();
+            String srcPath = path + "data/";
+            String glbPath = path + sid + ".glb";
 
         FileUtil.del(path);
 
@@ -116,10 +119,24 @@ public class BoxModelServiceImpl implements IBoxModelService {
             throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
         }
 
-        //上传glb
-        fYunFileService.uploadFile(bucket, glbPath, String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels/" + sid + ".glb");
+            //上传glb
+            fYunFileService.uploadFile(bucket, glbPath, String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels/" + sid + ".glb");
+
+            //上传原始obj相关文件
+            List<File> files = FileUtil.loopFiles(srcPath);
+            files.stream().forEach(v->{
+                String ossKey = String.format(UploadFilePath.USER_EDIT_PATH, num) + "boxModels/" + sid + "/" + v.getAbsolutePath().replace(srcPath, "");
+                fYunFileService.uploadFile(v.getAbsolutePath(), ossKey);
+            });
+
+            return ResultData.ok(sid + ".glb");
 
-        return ResultData.ok(sid + ".glb");
+        }catch (Exception e){
+            log.error("上传三维模型失败", e);
+            throw e;
+        }finally {
+            FileUtil.del(path);
+        }
     }
 
     public static void main(String[] args) {