dengsixing 1 mesiac pred
rodič
commit
09de84a829

+ 11 - 4
4dkankan-common-utils/src/main/java/com/fdkankan/common/util/JwtUtil.java

@@ -59,7 +59,7 @@ public class JwtUtil {
             //设置过期时间
             builder.setExpiration(exp);
         }/*else{
-            //设置过期时间半小时
+            //设置过期时间半小时main
             DateTime expDate = new DateTime().plusMinutes(30);
             builder.setExpiration(expDate.toDate());
         }*/
@@ -137,9 +137,16 @@ public class JwtUtil {
     }
 
     public static void main(String[] args) {
-        long start = System.currentTimeMillis();
-        System.out.println(getUsername("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzUzNjUwMTEyOCIsImxvZ2luVHlwZSI6InVzZXIiLCJ1c2VyTmFtZSI6IjEzNTM2NTAxMTI4IiwiaWF0IjoxNjU4ODI4NjA2LCJqdGkiOiI4NjczYjFiMi0xYjc4LTRmMTEtOGQ5My05OWE0OWRlMGVhMjAifQ.0oYzEwTsV1iLn_cMeiqLc5upJfcYipRbIDSndSxeuK0"));
-        System.out.println(System.currentTimeMillis() - start);
+//        long start = System.currentTimeMillis();
+//        System.out.println(getUsername("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMzUzNjUwMTEyOCIsImxvZ2luVHlwZSI6InVzZXIiLCJ1c2VyTmFtZSI6IjEzNTM2NTAxMTI4IiwiaWF0IjoxNjU4ODI4NjA2LCJqdGkiOiI4NjczYjFiMi0xYjc4LTRmMTEtOGQ5My05OWE0OWRlMGVhMjAifQ.0oYzEwTsV1iLn_cMeiqLc5upJfcYipRbIDSndSxeuK0"));
+//        System.out.println(System.currentTimeMillis() - start);
+
+        //eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIiLCJsb2dpblR5cGUiOiJ1c2VyIiwidXNlck5hbWUiOiIiLCJpYXQiOjE3NTE4NzA5MDIsImp0aSI6IjgyMmZiYjE0LTAwMDAtNGZhNC04NzA4LTc0YTI2MDdmZjJiOSJ9.gRIFvIUamFtYvIr5dZJ41dqhx9E3pPW866ZasERL8fw
+
+        String user = JwtUtil.createJWT(-1, "", "user");
+//        Claims claims = JwtUtil.parseJWT("eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIiLCJsb2dpblR5cGUiOiJ1c2VyIiwidXNlck5hbWUiOiIiLCJpYXQiOjE3NTE4NzA5MDIsImp0aSI6IjgyMmZiYjE0LTAwMDAtNGZhNC04NzA4LTc0YTI2MDdmZjJiOSJ9.gRIFvIUamFtYvIr5dZJ41dqhx9E3pPW866ZasERL8fw");
+        System.out.println(user);
+
     }
 
 }

+ 15 - 0
4dkankan-utils-fyun-cos/src/main/java/com/fdkankan/fyun/oss/CosFileService.java

@@ -264,6 +264,21 @@ public class CosFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                cosClient.copyObject(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+            });
+        } catch (Exception e) {
+            log.error("复制文件或目录失败,key:" + sourcePath, e);
+        }
+    }
+
+    @Override
     public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
         if (ObjectUtils.isEmpty(pathMap)) {
             return;

+ 5 - 0
4dkankan-utils-fyun-https/src/main/java/com/fdkankan/fyun/http/HttpFileService.java

@@ -229,6 +229,11 @@ public class HttpFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+
+    }
+
+    @Override
     public void copyFilesBetweenBucket(String sourceBucketName, String targetBucketName, Map<String, String> pathMap) {
         if (ObjectUtils.isEmpty(pathMap)) {
             return;

+ 5 - 0
4dkankan-utils-fyun-local/src/main/java/com/fdkankan/fyun/local/LocalFileService.java

@@ -93,6 +93,11 @@ public class LocalFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        this.copyFileBetweenBucket(sourceBucketName,sourcePath,targetBucketName, targetPath);
+    }
+
+    @Override
     public void downloadByCommand(String bucket, String filePath, String remoteFilePath, boolean isDir) {
         try {
             String optType = isDir ? "folder" : "file";

+ 17 - 0
4dkankan-utils-fyun-obs/src/main/java/com/fdkankan/fyun/oss/ObsFileService.java

@@ -68,6 +68,23 @@ public class ObsFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                CopyObjectRequest copyObjectRequest = new CopyObjectRequest(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+                copyObjectRequest.setAcl(AccessControlList.REST_CANNED_PUBLIC_READ);
+                obsClient.copyObject(copyObjectRequest);
+            });
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key:" + sourcePath, e);
+        }
+    }
+
+    @Override
     public String uploadFile(String bucket, String filePath, String remoteFilePath, Map<String, String> headers) {
         try {
             File file = new File(filePath);

+ 15 - 0
4dkankan-utils-fyun-oss/src/main/java/com/fdkankan/fyun/oss/OssFileService.java

@@ -243,6 +243,21 @@ public class OssFileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                ossClient.copyObject(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+            });
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key:" + sourcePath, e);
+        }
+    }
+
+    @Override
     public void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
         try {
             List<String> files = listRemoteFiles(sourceBucketName, sourcePath);

+ 4 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/AbstractFYunFileService.java

@@ -92,6 +92,10 @@ public abstract class AbstractFYunFileService implements FYunFileServiceInterfac
         copyFileBetweenBucket(fYunFileConfig.getBucket(), sourcePath, fYunFileConfig.getBucket(), targetPath);
     }
 
+    public void copyFileInBucketParallel(String sourcePath, String targetPath) {
+        copyFileBetweenBucketParallel(fYunFileConfig.getBucket(), sourcePath, fYunFileConfig.getBucket(), targetPath);
+    }
+
     @Override
     public void copyFileToArchive(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
         copyFileToArchive(sourceBucketName, sourcePath, targetBucketName, targetPath);

+ 4 - 0
4dkankan-utils-fyun-parent/src/main/java/com/fdkankan/fyun/face/FYunFileServiceInterface.java

@@ -235,6 +235,8 @@ public interface FYunFileServiceInterface {
      **/
     void copyFileInBucket(String sourcePath, String targetPath) ;
 
+    void copyFileInBucketParallel(String sourcePath, String targetPath) ;
+
     /**
      * <p>
      * 拷贝目录
@@ -247,6 +249,8 @@ public interface FYunFileServiceInterface {
      **/
     void copyFileBetweenBucket(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) ;
 
+    void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) ;
+
     /**
      * <p>
      * 拷贝目录

+ 17 - 0
4dkankan-utils-fyun-s3/src/main/java/com/fdkankan/fyun/s3/S3FileService.java

@@ -131,6 +131,23 @@ public class S3FileService extends AbstractFYunFileService {
     }
 
     @Override
+    public void copyFileBetweenBucketParallel(String sourceBucketName, String sourcePath, String targetBucketName, String targetPath) {
+        try {
+            List<String> files = listRemoteFiles(sourceBucketName, sourcePath);
+            if (ObjectUtils.isEmpty(files)) {
+                return;
+            }
+            files.parallelStream().forEach(file -> {
+                CopyObjectRequest request = new CopyObjectRequest(sourceBucketName, file, targetBucketName, file.replace(sourcePath, targetPath));
+                request.withCannedAccessControlList(CannedAccessControlList.PublicRead);
+                s3.copyObject(request);
+            });
+        } catch (Exception e) {
+            log.error("列举文件目录失败,key=" + sourcePath);
+        }
+    }
+
+    @Override
     public void downloadFileByCommand(String bucket, String filePath, String remoteFilePath) {
         try {
             String optType = remoteFilePath.contains(".") ? "file" : "folder";