yangdamao 2 سال پیش
والد
کامیت
89b907e595

+ 23 - 1
zhongzheng-admin/src/main/java/com/zhongzheng/controller/common/CommonController.java → zhongzheng-admin/src/main/java/com/zhongzheng/controller/CommonController.java

@@ -1,4 +1,4 @@
-package com.zhongzheng.controller.common;
+package com.zhongzheng.controller;
 
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -25,6 +25,8 @@ import org.springframework.web.multipart.MultipartFile;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -105,6 +107,26 @@ public class CommonController extends BaseController {
         return AjaxResult.success(fileNameList);
     }
 
+    /**
+     * 本地文件删除
+     */
+    @GetMapping("/common/del/file")
+    public AjaxResult<Void> delFile() {
+        String zhiyuan = System.getProperty("user.dir");
+        String toPath = zhiyuan + "/zhongzheng-admin/src/main/resources/zhiyuan";
+        File directory = new File(toPath);
+        try {
+            Files.walk(directory.toPath())
+                    .filter(Files::isRegularFile)
+                    .map(Path::toFile)
+                    .forEach(File::delete);
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new CustomException(e.getMessage());
+        }
+        return AjaxResult.success();
+    }
+
     /**
      * 文件分片处理
      */

+ 2 - 0
zhongzheng-framework/src/main/java/com/zhongzheng/framework/config/SecurityConfig.java

@@ -135,7 +135,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/common/jzs/**").anonymous()
                 .antMatchers("/common/rollback/period").anonymous()
                 .antMatchers("/common/decompression").anonymous()
+                .antMatchers("/common/del/file").anonymous()
                 .antMatchers("/common/merge/file").anonymous()
+                .antMatchers("/exam/*").anonymous()
                 .antMatchers("/common/delete/file").anonymous()
                 .antMatchers("/course/handouts/**").anonymous()
                 .antMatchers("/common/get/goods").anonymous()