From 66232862129c84f2c98fabdc73a59f4fe0e0a360 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期三, 11 九月 2024 22:26:21 +0800
Subject: [PATCH] 视频专网端代码初始化

---
 ruoyi-admin/src/main/resources/application-prod.yml                                                 |   10 ++--
 ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java                  |   19 ++-------
 ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysOssController.java |   64 ++++++++++++++++----------------
 3 files changed, 42 insertions(+), 51 deletions(-)

diff --git a/ruoyi-admin/src/main/resources/application-prod.yml b/ruoyi-admin/src/main/resources/application-prod.yml
index 49018d9..1a04cd2 100644
--- a/ruoyi-admin/src/main/resources/application-prod.yml
+++ b/ruoyi-admin/src/main/resources/application-prod.yml
@@ -46,12 +46,12 @@
 #          url: jdbc:mysql://123.207.71.245:13306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
 #          username: root
 #          password: 234#Wersdf!
-          url: jdbc:mysql://80.36.32.176:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
-          username: root
-          password: 234#Wersdf!
-#          url: jdbc:mysql://51.9.57.211:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
+#          url: jdbc:mysql://80.36.32.176:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
 #          username: root
 #          password: 234#Wersdf!
+          url: jdbc:mysql://51.9.57.211:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
+          username: root
+          password: 234#Wersdf!
 #          url: jdbc:mysql://172.35.50.34:3306/qysp?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true
 #          username: root
 #          password: 234#Wersdf!
@@ -105,7 +105,7 @@
 spring.data:
   redis:
     # 鍦板潃
-    host: 80.36.32.176
+    host: 127.0.0.1
     # 绔彛锛岄粯璁や负6379
     port: 6379
     password: 234#Wersdf!
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysOssController.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysOssController.java
index a5b58ae..9765cf1 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysOssController.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysOssController.java
@@ -89,47 +89,47 @@
         return R.ok(list);
     }
 
-//    /**
-//     * 涓婁紶OSS瀵硅薄瀛樺偍  瑙嗛涓撶綉
-//     *
-//     * @param file 鏂囦欢
-//     */
-//    @SaCheckPermission("system:oss:upload")
-//    @Log(title = "OSS瀵硅薄瀛樺偍", businessType = BusinessType.INSERT)
-//    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
-//    public R<SysOssUploadVo> upload(@RequestPart("file") MultipartFile file) throws IOException {
-//
-//        if (ObjectUtil.isNull(file)) {
-//            return R.fail("涓婁紶鏂囦欢涓嶈兘涓虹┖");
-//        }
-//        SysOssVo oss = ossService.upload(file);
-//
-//        SysOssUploadVo uploadVo = new SysOssUploadVo();
-//        uploadVo.setUrl(oss.getUrl());
-//        uploadVo.setFileName(oss.getOriginalName());
-//        uploadVo.setOssId(oss.getOssId().toString());
-//        uploadVo.setPassword(oss.getPassword());
-//
-//        return R.ok(uploadVo);
-//    }
-
     /**
-     * 涓婁紶OSS瀵硅薄瀛樺偍  浜掕仈缃�
+     * 涓婁紶OSS瀵硅薄瀛樺偍  瑙嗛涓撶綉
      *
      * @param file 鏂囦欢
      */
     @SaCheckPermission("system:oss:upload")
     @Log(title = "OSS瀵硅薄瀛樺偍", businessType = BusinessType.INSERT)
     @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
-    public R<String> upload(@RequestPart("file") MultipartFile file) throws IOException {
-        String originalfileName = file.getOriginalFilename();
-        long l = System.currentTimeMillis();
-        String password = PasswordUtil.randomPassword(6);
-        String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
-        FtpApche.uploadFile(ftpConfig, file, password + String.valueOf(l) + suffix);
-        return R.ok(password);
+    public R<SysOssUploadVo> upload(@RequestPart("file") MultipartFile file) throws IOException {
+
+        if (ObjectUtil.isNull(file)) {
+            return R.fail("涓婁紶鏂囦欢涓嶈兘涓虹┖");
+        }
+        SysOssVo oss = ossService.upload(file);
+
+        SysOssUploadVo uploadVo = new SysOssUploadVo();
+        uploadVo.setUrl(oss.getUrl());
+        uploadVo.setFileName(oss.getOriginalName());
+        uploadVo.setOssId(oss.getOssId().toString());
+        uploadVo.setPassword(oss.getPassword());
+
+        return R.ok(uploadVo);
     }
 
+//    /**
+//     * 涓婁紶OSS瀵硅薄瀛樺偍  浜掕仈缃�
+//     *
+//     * @param file 鏂囦欢
+//     */
+//    @SaCheckPermission("system:oss:upload")
+//    @Log(title = "OSS瀵硅薄瀛樺偍", businessType = BusinessType.INSERT)
+//    @PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
+//    public R<String> upload(@RequestPart("file") MultipartFile file) throws IOException {
+//        String originalfileName = file.getOriginalFilename();
+//        long l = System.currentTimeMillis();
+//        String password = PasswordUtil.randomPassword(6);
+//        String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."), originalfileName.length());
+//        FtpApche.uploadFile(ftpConfig, file, password + String.valueOf(l) + suffix);
+//        return R.ok(password);
+//    }
+//
     private String post(VideoRequest request) throws IOException {
         HashMap<String, String> headers = new HashMap<>(3);
         String requestUrl = boundary.getChief() + "/resource/synchronization/uploadTwo";
diff --git a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
index 17bbfed..2dba841 100644
--- a/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
+++ b/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/sync/VideoPulSync.java
@@ -53,24 +53,15 @@
             return;
         }
         for (String str : list) {
-            //瀵嗙爜
-            String password = str.substring(0,6);
-            //鏂囦欢鍚嶇О
-            String fileName = str.substring(6,str.length());
+            String password = str.substring(0, 6);
+            String fileName = str.substring(6, str.length());
             InputStream input = FtpApche.downloadFileFromDailyDir(str);
             byte[] fileBytesByName = FtpApche.getFileBytesByName(input);
             OssClient storage = OssFactory.instance();
-            MultipartFile file = new MockMultipartFile(fileName,fileName, fileName.substring(14,fileName.length()), input);
-//            UploadResult uploadResult = storage.upload(input,getPath(fileName),"multipart/form-data; charset=ISO-8859-1");
-            UploadResult uploadResult;
-//            try {
-                uploadResult = storage.uploadSuffix2(fileBytesByName, getPath(fileName), "multipart/form-data; charset=ISO-8859-1");
-
+            MockMultipartFile mockMultipartFile = new MockMultipartFile(fileName, fileName, fileName.substring(14, fileName.length()), input);
+            UploadResult uploadResult = storage.uploadSuffix2(fileBytesByName, getPath(fileName), "multipart/form-data; charset=ISO-8859-1");
             FtpApche.deleteFile(str);
-            input.close();
-//            buildResultEntity(fileName, fileName.substring(14,fileName.length()), "minio", uploadResult, file,
-//                password, fileBytesByName);
-
+            buildResultEntity(fileName, fileName.substring(14, fileName.length()), "minio", uploadResult, (MultipartFile)mockMultipartFile, password, fileBytesByName);
         }
 
     }

--
Gitblit v1.8.0