فهرست منبع

融云消息导入

haonan 1 سال پیش
والد
کامیت
f0d0dc4e87

+ 18 - 23
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/ImGroupController.java

@@ -91,43 +91,38 @@ public class ImGroupController extends BaseController {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(currentDate);
 
-        // 将日期减少
-        calendar.add(Calendar.DATE, -1);
+        // 将日期减少
+        calendar.add(Calendar.DATE, -3);
 
-        // 获取减少天后的日期
+        // 获取减少天后的日期
         Date tommorow = calendar.getTime();
 
         calendar.setTime(currentDate);
 
         //按照小时递减
         while (currentDate.after(tommorow)) {
-            String d = DateUtil.format(DateUtil.addHours(currentDate, 0), DateUtil.YEAR_MONTH_DAY_HOUR);
-            Object o = imGroupService.historyGet(d);
-            JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o));
-            if (jsonObject.get("code").equals(200)) {
-                /*Boolean success = redisCache.getRedisTemplate().opsForValue().setIfAbsent("syncImHistoryMessage" + d,d);
-                if(!success){
-                    return;
-                }*/
-                String url = jsonObject.getString("url");
-                /*if(StringUtils.isEmpty(url)){
-                    return;
-                }*/
-                if (!StringUtils.isEmpty(url)) {
-                    File file = new File(FileUtils.getTempDirectoryPath() + url.substring(url.lastIndexOf("/")));
-                    URL url1 = new URL(url);
-                    FileUtils.copyURLToFile(url1, file);
-                    imGroupService.saveImHistoryMessage(new File(file.getAbsolutePath()));
-                }
-
-            }
+            RongyunImport(currentDate);
             calendar.add(Calendar.HOUR, -1);
             currentDate = calendar.getTime();
         }
 
     }
 
+    private void RongyunImport(Date currentDate) throws Exception {
+        String d = DateUtil.format(DateUtil.addHours(currentDate, 0), DateUtil.YEAR_MONTH_DAY_HOUR);
+        Object o = imGroupService.historyGet(d);
+        JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(o));
+        if (jsonObject.get("code").equals(200)) {
+            String url = jsonObject.getString("url");
+            if (!StringUtils.isEmpty(url)) {
+                File file = new File(FileUtils.getTempDirectoryPath() + url.substring(url.lastIndexOf("/")));
+                URL url1 = new URL(url);
+                FileUtils.copyURLToFile(url1, file);
+                imGroupService.saveImHistoryMessage(new File(file.getAbsolutePath()));
+            }
 
+        }
+    }
 
 
 }

+ 1 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dao/ImGroupDao.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.yonge.cooleshow.biz.dal.dto.ImGroupResultDto;
 import com.yonge.cooleshow.biz.dal.dto.ImGroupSearchDto;
 import com.yonge.cooleshow.biz.dal.entity.ImGroup;
+import com.yonge.cooleshow.biz.dal.entity.ImHistoryMessage;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;

+ 84 - 3
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/ImHistoryMessage.java

@@ -1,9 +1,90 @@
 package com.yonge.cooleshow.biz.dal.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
 /**
  * @Author:haonan
- * @Date:2023/8/14 11:35
+ * @Date:2023/8/7 15:17
  * @Filename:ImHistoryMessage
  */
-public class ImHistoryMessage {
-}
+@Data
+@ApiModel(" ImHistoryMessage-历史消息记录")
+@TableName("im_history_message")
+public class ImHistoryMessage implements Serializable {
+
+    @ApiModelProperty("可通过 msgUID 确定消息唯一")
+    @TableId(value = "msgUID_")
+    private String msgUID;
+
+    @ApiModelProperty("发送者 ID")
+    @TableField(value = "fromUserId_")
+    private String fromUserId;
+
+    @ApiModelProperty("接收者 ID,在消息路由中为 toUserId,当发送聊天室广播消息、全量用户落地通知时此字段为空")
+    @TableField(value = "targetId_")
+    private String targetId;
+
+    @ApiModelProperty("会话类型。1(单聊会话)、2(讨论组会话)、3(群组会话)、4(聊天室会话)、5(客服会话)、6(系统通知)、7(应用公众服务)、8(公众服务)、10(超级群会话)。targetType 在 SDK 中为 ConversationType。")
+    @TableField(value = "targetType_")
+    private Integer targetType;
+
+    @ApiModelProperty("根据不同的 targetType,可能是讨论组 Id、群组 ID、超级群 ID 或聊天室 ID ,如 targetType 为 1 时可忽略 GroupId")
+    @TableField(value = "GroupId_")
+    private String groupId;
+
+    @ApiModelProperty("	超级群频道 ID。")
+    @TableField(value = "busChannel_")
+    private String busChannel;
+
+    @ApiModelProperty("消息类型,例如文本消息 RC:TxtMsg、图片消息 RC:ImgMsg")
+    @TableField(value = "classname_")
+    private String classname;
+
+    @ApiModelProperty("消息内容")
+    @TableField(value = "content_")
+    private String content;
+
+    @ApiModelProperty("消息扩展")
+    @TableField(value = "extraContent_")
+    private String extraContent;
+
+    @ApiModelProperty("消息时间")
+    @TableField(value = "dateTime_")
+    private String dateTime;
+
+    @ApiModelProperty("消息来源,包括:iOS、Android、Websocket、MiniProgram(小程序)、PC、Server。")
+    @TableField(value = "source_")
+    private String source;
+
+    @ApiModelProperty("是否被丢弃,true 为是,false 为否,只针对聊天室会话类型存在。")
+    @TableField(value = "isDiscard_")
+    private String isDiscard;
+
+    @ApiModelProperty("是否含有屏蔽敏感词,true 为含有、false 为不含有。只针对聊天室会话类型存在。")
+    @TableField(value = "isSensitiveWord_")
+    private String isSensitiveWord;
+
+    @ApiModelProperty("是否为被禁言后发送的消息,只针对聊天室会话类型存在。")
+    @TableField(value = "isForbidden_")
+    private String isForbidden;
+
+    @ApiModelProperty("	消息是否不分发,true 为不分发、false 为分发。只针对聊天室会话类型存在。")
+    @TableField(value = "isNotForward_")
+    private String isNotForward;
+
+    @ApiModelProperty("targetType 为 3 时此参数有效,显示为群组中指定接收消息的用户 ID 数组,该条消息为群组定向消息。非定向消息时内容为空,如指定的用户不在群组中内容也为空。")
+    @TableField(value = "groupUserIds_")
+    private String groupUserIds;
+
+    @ApiModelProperty("App Key")
+    @TableField(value = "appId_")
+    private String appId;
+}

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

@@ -41,6 +41,7 @@ import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -93,6 +94,11 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
     @Autowired
     private StudentStarService studentStarService;
 
+    @Value("${cn.rongcloud.im.appkey}")
+    private String appKey;
+    @Value("${cn.rongcloud.im.secret}")
+    private String appSecret;
+
     @Override
     public ImGroupDao getDao() {
         return this.baseMapper;