Bladeren bron

异步删除文件

wuweihao 3 jaren geleden
bovenliggende
commit
6bd252cec3

+ 8 - 2
720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -3,6 +3,7 @@ package com.gis.common.util;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.img.Img;
 import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.URLUtil;
 import com.gis.common.constant.ConfigConstant;
@@ -784,8 +785,13 @@ public class FileUtils {
     public void del(String path){
         if (StrUtil.isNotBlank(path)){
             String delPath = configConstant.serverBasePath + path;
-            FileUtil.del(delPath);
-            log.info("真删除文件: {}", delPath);
+            // 异步执行
+            ThreadUtil.execAsync(() -> {
+                FileUtil.del(delPath);
+                log.info("真删除文件: {}", delPath);
+            });
+
+
         }
 
     }

+ 2 - 31
720yun_fd_manage/gis_web/src/main/java/com/gis/web/controller/FodderController.java

@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.log4j.Log4j2;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -30,7 +31,7 @@ import java.util.List;
 /**
  * Created by owen on 2020/2/18 0018 12:17
  */
-@Log4j2
+@Slf4j
 @Api(tags = "我的素材")
 @RestController
 @RequestMapping("manage/fodder")
@@ -78,36 +79,6 @@ public class FodderController extends BaseController {
         return Result.success();
     }
 
-//    @ApiOperation(value = "删除", position = 1)
-//    @PostMapping("remove/{id}")
-//    public Result remove( @PathVariable Long id) {
-//        FodderEntity entity = fodderService.findById(id);
-//        if (entity == null) {
-//            return Result.failure("对象不存在, id: " + id);
-//        }
-//
-//        // 检查全景图是否被引用
-//        if ("pano".equals(entity.getType())) {
-//
-//            if (entity.getStatus() == 1) {
-//                return Result.failure("计算中的场景不能删除");
-//            }
-//
-//            List<WorkEntity> list = workService.likeSceneCode(entity.getSceneCode());
-//            if (list.size() > 0) {
-//                return Result.failure(MsgCode.e3007,"素材已经被引用, 不能删除");
-//            }
-//
-//
-//        }
-//
-//        entity.setIsDelete(1);
-//        entity.setUpdateTime(new Date());
-//        fodderService.update(entity);
-//        return Result.success();
-//    }
-
-
 
     @ApiOperation(value = "删除", position = 1)
     @PostMapping("remove/{id}")