Procházet zdrojové kódy

上传文件接口增加耗时打印

dengsixing před 2 roky
rodič
revize
3357a09dc2

+ 3 - 1
src/main/java/com/fdkankan/scene/controller/TestController.java

@@ -24,10 +24,12 @@ public class TestController {
     private FYunFileServiceInterface fYunFileServiceInterface;
     @Autowired
     private ISceneCleanService sceneCleanService;
+    @Autowired
+    private FYunFileServiceInterface fYunFileService;
 
     @GetMapping("/test")
     public ResultData test(){
-        sceneCleanService.sceneCleanResource();
+        fYunFileService.uploadFile("4dkankan","C:\\Users\\4dage\\Downloads\\4DKanKan_share.png", "test_1/test.png");
         return ResultData.ok();
     }
 

+ 3 - 5
src/main/java/com/fdkankan/scene/service/impl/SceneUploadServiceImpl.java

@@ -117,7 +117,6 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
 
     public String uploadFiles(String sendFileName,String bizType,List<MultipartFile> files,
         String num, Integer type,Long userId, String uploadPath) throws Exception{
-        TimeInterval timer = DateUtil.timer();
         if (StrUtil.isEmpty(num))
             throw new BusinessException(ServerCode.PARAM_REQUIRED, "num");
         if(CollUtil.isEmpty(files))
@@ -151,22 +150,21 @@ public class SceneUploadServiceImpl extends ServiceImpl<ISceneUploadMapper, Scen
             realFileName = realFileName.substring(0, realFileName.lastIndexOf(oldExtName)) + newExtName;
 
             String ossPath = StrUtil.isNotBlank(uploadPath) ? uploadPath : (String.format(UploadFilePath.USER_EDIT_PATH ,num) + realFileName);
-            System.out.println(timer.intervalRestart());
             try {
+                TimeInterval timer = DateUtil.timer();
                 fYunFileService.uploadFile(bucket, newFile.getPath(), ossPath);
+                System.out.println(timer.intervalRestart());
             }catch (Exception e){
                 log.error(ossPath+"上传文件失败"+e);
                 throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
             }
-            System.out.println(timer.intervalRestart());
+
             urlList.add(realFileName);
 
             FileUtils.delFile(newFile.getPath());
             //添加记录
             this.saveData(num,ossPath,bizType,userId);
-            System.out.println(timer.intervalRestart());
         }
-        System.out.println(timer.intervalRestart());
         StringBuilder returnString = new StringBuilder();
         for (String res : urlList) {
             if(StringUtils.isNotBlank(returnString)){