|
|
@@ -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();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 文件分片处理
|
|
|
*/
|