From 25b7ce0742103b9cbaf21aae06c2cf12d4872764 Mon Sep 17 00:00:00 2001
From: zhanghua <314079846@qq.com>
Date: 星期三, 13 九月 2023 11:11:05 +0800
Subject: [PATCH] 视频上传

---
 ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java |   52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java b/ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java
index f8f7622..05f98c7 100644
--- a/ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java
+++ b/ycl-platform/src/main/java/com/ycl/controller/dingding/DingController.java
@@ -19,18 +19,23 @@
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import static com.ycl.common.constant.DingConst.GET_TIKER;
-import static com.ycl.common.constant.DingConst.GET_TOKEN;
+import static com.ycl.common.constant.DingConst.*;
 
 @RestController
 @RequestMapping("/ding")
@@ -137,7 +142,6 @@
     @GetMapping("/addressBook")
     public CommonResult<List<AddressBookVO>> getAddressBook() {
         AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
-
         return CommonResult.success(dingService.getAddressBook(user.getUserId()));
     }
 
@@ -165,5 +169,47 @@
         return CommonResult.success(bookRemarkService.updateRemark(user, userId, remark));
     }
 
+    private String getVideo(String accToken) {
+        CloseableHttpResponse response = null;
+        //璋冪敤API
+        GetClient getClient = executableClient.newGetClient(GET_VIDEO);
+        //璁剧疆鍙傛暟
+        try {
+            if (ObjectUtil.isNotNull(accToken)) {
+            getClient.addParameter("accessToken", accToken);
+            getClient.addParameter("mediaId", dingConfig.getMediaId());
+//            String result = getClient.get();
+//            return parsingResult(result);
+            response = getClient.getB();
+            HttpEntity entity = response.getEntity();
+            InputStream is = entity.getContent();
+            File voice = new File("/Users/video/log1.xlsx");
+            OutputStream fos = new FileOutputStream(voice);
+            int cache = 10 * 1024;
+            byte[] buffer = new byte[cache];
+            int ch = 0;
+                while ((ch = is.read(buffer)) != -1) {
+                fos.write(buffer, 0, ch);
+                }
+            is.close();
+            fos.flush();
+            fos.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            if (response != null) {
+                try {
+                    //鐗瑰埆鎻愰啋锛氶渶瑕佽皟鐢╮esponse鐨刢lose鏂规硶鍏抽棴缃戠粶杩炴帴锛侊紒锛�
+                    response.close();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return null;
+    }
+
+
 
 }

--
Gitblit v1.8.0