Przeglądaj źródła

更新忽略文件

gjs 3 lat temu
rodzic
commit
568b7b8294

+ 17 - 21
src/main/java/com/macro/mall/tiny/modules/business/controller/FileController.java

@@ -15,12 +15,13 @@ import com.macro.mall.tiny.security.util.AuthUtil;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.compress.archivers.zip.*;
+import org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
 import org.apache.commons.compress.parallel.InputStreamSupplier;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.io.ClassPathResource;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.validation.annotation.Validated;
@@ -31,18 +32,13 @@ import javax.servlet.http.HttpServletResponse;
 import javax.websocket.server.PathParam;
 import java.io.*;
 import java.net.URLEncoder;
-import java.nio.charset.Charset;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 import java.util.ArrayList;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
+import java.util.Map;
 import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
 
 /**
  * 大文件上传
@@ -120,7 +116,7 @@ public class FileController {
     }
 
     /**
-     * @param path
+     * @param params
      * @return com.macro.mall.tiny.common.api.CommonResult<java.util.List < com.macro.mall.tiny.modules.business.model.BFileDetail>>
      * @describe 获取文件夹下全被文件详细接口
      * @author gjs
@@ -128,27 +124,27 @@ public class FileController {
      * @since J7.23.0
      */
     @ApiOperation("获取文件夹下全部文件详细接口")
-    @GetMapping("/getFileDetail")
-    public CommonResult<List<BFileDetail>> getFileDetail(@RequestParam @PathParam(value = "path") String path) {
+    @PostMapping("/getFileDetail")
+    public CommonResult<List<BFileDetail>> getFileDetail(@RequestBody Map<String,String> params) {
         AdminUserDetails userDetails = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-        List<BFileDetail> fileDetailList = fileService.getFileDetailList(path, userDetails);
+        List<BFileDetail> fileDetailList = fileService.getFileDetailList(params.get("path"), userDetails);
         return CommonResult.success(fileDetailList);
     }
 
     @ApiOperation("获取文件夹下全部文件/文件夹")
-    @GetMapping("/getFile")
-    public CommonResult<List<BFile>> getFile(@RequestParam @PathParam(value = "path") String path) {
+    @PostMapping("/getFile")
+    public CommonResult<List<BFile>> getFile(@RequestBody Map<String,String> params) {
         AdminUserDetails userDetails = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-        List<BFile> fileDetailList = fileService.getFileList(path, userDetails);
+        List<BFile> fileDetailList = fileService.getFileList(params.get("path"), userDetails);
         return CommonResult.success(fileDetailList);
     }
 
     @ApiOperation("文件下载接口")
-    @GetMapping("/download")
-    public void downLoad(HttpServletResponse response, @RequestParam @PathParam(value = "path") String path) throws Exception {
+    @PostMapping("/download")
+    public void downLoad(HttpServletResponse response, @RequestBody Map<String,String> params) throws Exception {
         AdminUserDetails userDetails = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
         boolean access = AuthUtil.checkAccess(userDetails, AuthUtil.ACCESS);
-        File file = new File(path);
+        File file = new File(params.get("path"));
         if (file.getName().contains(String.valueOf(UploadConfig.AUTH_STR)) && !access) return;
         if (file.exists()) { //判断文件父目录是否存在
             String fileName = file.getName();
@@ -220,10 +216,10 @@ public class FileController {
     }
 
     @ApiOperation("文件删除接口")
-    @GetMapping("/delete")
-    public CommonResult<String> delete(@RequestParam @PathParam(value = "path") String path) throws IOException {
+    @PostMapping("/delete")
+    public CommonResult<String> delete(@RequestBody Map<String,String> params) throws IOException {
         AdminUserDetails userDetails = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-        boolean deleteFile = fileService.deleteFile(path, userDetails);
+        boolean deleteFile = fileService.deleteFile(params.get("path"), userDetails);
         if (deleteFile) {
             return CommonResult.success("删除成功");
         } else {