Browse Source

fix视频消息

haonan 2 years ago
parent
commit
34661996bb

+ 0 - 4
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/ImGroupController.java

@@ -152,10 +152,6 @@ public class ImGroupController extends BaseController {
             info = imGroupService.getRongYunInfo(page,size);
             //IM导入
             imGroupService.importInfo(info);
-
-            //为已导入数据更改标识
-            imGroupService.updateStatus(info);
-
         }
     }
 

+ 1 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/UploadFileService.java

@@ -59,9 +59,7 @@ public class UploadFileService {
             uploadReturn.setMessage("上传图片格式错误,目前只支持" + supportType);
             return uploadReturn;
         }
-
-        String root = "d:";
-                //fileRoot;
+        String root = fileRoot;
         if (StringUtils.isBlank(root)) {
             uploadReturn.setMessage("上传临时目录没有配置");
             return uploadReturn;

+ 7 - 22
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/ImGroupServiceImpl.java

@@ -765,10 +765,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
                     String size = jsonObject.getString("size");
                     int duration = jsonObject.getInteger("duration");
                     String content = jsonObject.getString("content");
-                    String name = jsonObject.getString("name");
                     TencentRequest.MessageBody body1 = null;
                     try {
-                        body1 = getTimVideoFileElem(sightUrl,size,duration,content,name);
+                        body1 = getTimVideoFileElem(sightUrl,size,duration,content);
                     } catch (IOException e) {
                         e.printStackTrace();
                     }
@@ -891,10 +890,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
                     String size = jsonObject.getString("size");
                     int duration = jsonObject.getInteger("duration");
                     String content = jsonObject.getString("content");
-                    String name = jsonObject.getString("name");
                     TencentRequest.MessageBody body1 = null;
                     try {
-                        body1 = getTimVideoFileElem(sightUrl,size,duration,content,name);
+                        body1 = getTimVideoFileElem(sightUrl,size,duration,content);
                     } catch (IOException e) {
                         e.printStackTrace();
                     }
@@ -938,6 +936,8 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
                 groupImportMessage.setMsgList(list);
                 try {
                     imPluginContext.getPluginService().importGroupMessage(groupImportMessage);
+                    //为已导入数据更改标识
+                    imGroupService.updateStatus(info);
                 } catch (Exception e) {
                     log.error("导入群组IM消息失败 msg:{}",list,e);
                 }
@@ -1012,7 +1012,7 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
     }
 
     //构建视频请求体
-    public  TencentRequest.MessageBody getTimVideoFileElem(String sightUrl, String size, int duration, String content,String name) throws IOException {
+    public  TencentRequest.MessageBody getTimVideoFileElem(String sightUrl, String size, int duration, String content) throws IOException {
         if (StringUtils.isEmpty(sightUrl) && StringUtils.isEmpty(sightUrl) && duration == 0) {
             return null;
         }
@@ -1028,26 +1028,9 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
             format = "JPG";
         }
 
-        //获取JDK8里的解码器Base64.Decoder,将base64字符串转为字节数组
-        //byte[] bytes = Base64.getDecoder().decode(content);
-        //构建字节数组输入流
-        //bais = new ByteArrayInputStream(bytes);
-
-            //获取图片类型
-            //String suffix = name.substring(name.lastIndexOf(".") + 1);
-            //获取JDK8里的解码器Base64.Decoder,将base64字符串转为字节数组
             byte[] bytes = Base64.getDecoder().decode(content);
             //构建字节数组输入流
             bais = new ByteArrayInputStream(bytes);
-           /* //通过ImageIO把字节数组输入流转为BufferedImage
-            BufferedImage bufferedImage = ImageIO.read(bais);
-
-            //构建文件
-            File imageFile = new File(name);
-            //写入生成文件
-            ImageIO.write(bufferedImage, format, imageFile);*/
-
-
 
 
 
@@ -1063,6 +1046,8 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
                 .suffix(format)
                 .build();
 
+        // 获取图片基本信息
+        ImageUtil.imageToBase64(imageReq);
 
         ImHistoryMessageWrapper.TimVideoFileElem timVideoFileElem = new ImHistoryMessageWrapper.TimVideoFileElem();
         timVideoFileElem.setVideoUrl(sightUrl);