zouxuan 2 سال پیش
والد
کامیت
aff9630a65

+ 3 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/ImLiveRoomBlackService.java

@@ -3,6 +3,7 @@ package com.ym.mec.biz.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.entity.ImLiveRoomBlack;
+import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo;
 import com.ym.mec.biz.dal.vo.ImLiveRoomBlackVo;
 import com.ym.mec.common.page.PageInfo;
 
@@ -53,10 +54,10 @@ public interface ImLiveRoomBlackService extends IService<ImLiveRoomBlack> {
     /**
      * 发送黑名单消息到直播房间
      *
-     * @param roomUid    房间uid
+     * @param roomVo    房间
      * @param fromUserId 发送人id
      * @param userId     用户id
      */
-    void sendBlackMsg(String roomUid, Integer fromUserId, Integer userId, String type);
+    void sendBlackMsg(ImLiveBroadcastRoomVo roomVo, Integer fromUserId, Integer userId, String type);
 }
 

+ 32 - 11
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ImLiveRoomBlackServiceImpl.java

@@ -5,11 +5,16 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.microsvc.toolkit.middleware.live.LivePluginContext;
+import com.microsvc.toolkit.middleware.live.LivePluginService;
+import com.microsvc.toolkit.middleware.live.message.LiveRoomMessage;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ImLiveRoomBlackDao;
 import com.ym.mec.biz.dal.entity.ImLiveRoomBlack;
+import com.ym.mec.biz.dal.vo.ImLiveBroadcastRoomVo;
 import com.ym.mec.biz.dal.vo.ImLiveRoomBlackVo;
+import com.ym.mec.biz.service.ImLiveBroadcastRoomService;
 import com.ym.mec.biz.service.ImLiveRoomBlackService;
 import com.ym.mec.common.entity.ImRoomMessage;
 import com.ym.mec.common.exception.BizException;
@@ -17,7 +22,6 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
-import com.ym.mec.im.ImFeignService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -40,7 +44,9 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
     @Autowired
     private SysUserFeignService sysUserFeignService;
     @Autowired
-    private ImFeignService imFeignService;
+    private LivePluginContext livePluginContext;
+    @Autowired
+    private ImLiveBroadcastRoomService imLiveBroadcastRoomService;
 
     /**
      * 查询当前机构学生 -下拉框
@@ -73,6 +79,7 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
     public void add(Map<String, Object> param) {
         String roomUid = WrapperUtil.toStr(param, "roomUid");
         List<String> userIdList = WrapperUtil.toList(WrapperUtil.toStr(param, "userIdList", "用户id不能为空"));
+
         userIdList.forEach(userIdStr -> {
             Integer userId = Integer.parseInt(userIdStr);
             int count = this.count(Wrappers.<ImLiveRoomBlack>lambdaQuery()
@@ -88,10 +95,16 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
             imLiveRoomBlack.setCreateBy(getSysUser().getId());
             imLiveRoomBlack.setCreateTime(new Date());
             this.save(imLiveRoomBlack);
+            ImLiveBroadcastRoomVo roomVo = imLiveBroadcastRoomService.queryRoomInfo(roomUid);
             //发送消息到直播房间
-            this.sendBlackMsg(roomUid, userId, userId, ImRoomMessage.BLOCK_BLACK_USER);
+            this.sendBlackMsg(roomVo, userId, userId, ImRoomMessage.BLOCK_BLACK_USER);
             //调用融云方法加入禁言
-            imFeignService.addUserUnableSpeak(roomUid, userIdStr);
+            LivePluginService pluginService = livePluginContext.getPluginService(roomVo.getServiceProvider());
+            try {
+                pluginService.chatRoomUserGagCreate(userIdStr, roomUid, -1);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
         });
     }
 
@@ -107,15 +120,21 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
     public void delete(Map<String, Object> param) {
         String roomUid = WrapperUtil.toStr(param, "roomUid");
         List<String> userIdList = WrapperUtil.toList(WrapperUtil.toStr(param, "userIdList", "用户id不能为空"));
+        ImLiveBroadcastRoomVo roomVo = imLiveBroadcastRoomService.queryRoomInfo(roomUid);
         userIdList.forEach(userIdStr -> {
             Integer userId = Integer.parseInt(userIdStr);
             this.remove(Wrappers.<ImLiveRoomBlack>lambdaQuery()
                     .eq(ImLiveRoomBlack::getRoomUid, roomUid)
                     .eq(ImLiveRoomBlack::getUserId, userId));
             //发送消息到直播房间
-            this.sendBlackMsg(roomUid, userId, userId, ImRoomMessage.UNBLOCK_BLACK_USER);
+            this.sendBlackMsg(roomVo, userId, userId, ImRoomMessage.UNBLOCK_BLACK_USER);
             //调用融云方法加入禁言
-            imFeignService.removeUserUnableSpeak(roomUid, userIdStr);
+            LivePluginService pluginService = livePluginContext.getPluginService(roomVo.getServiceProvider());
+            try {
+                pluginService.chatRoomuserGagRemove(userIdStr,roomUid);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
         });
     }
 
@@ -136,27 +155,29 @@ public class ImLiveRoomBlackServiceImpl extends ServiceImpl<ImLiveRoomBlackDao,
     /**
      * 发送黑名单消息到直播房间
      *
-     * @param roomUid    房间uid
+     * @param roomVo    房间uid
      * @param fromUserId 发送人id
      * @param userId     用户id
      */
-    public void sendBlackMsg(String roomUid, Integer fromUserId, Integer userId, String type) {
+    public void sendBlackMsg(ImLiveBroadcastRoomVo roomVo, Integer fromUserId, Integer userId, String type) {
+        String roomUid = roomVo.getRoomUid();
         //校验传入参数,房间uid和发送人id不能为空
         if (!WrapperUtil.checkObj(roomUid, fromUserId, userId, type)) {
             log.info(" sendBlackMsg>>>> param is null   roomUid: {}  fromUserId:{}  type:{}", roomUid, fromUserId, type);
             return;
         }
-        ImRoomMessage message = new ImRoomMessage();
+        LiveRoomMessage message = new LiveRoomMessage();
         message.setIsIncludeSender(1);
         message.setObjectName(type);
-        message.setToChatroomId(roomUid);
+        message.setToChatRoomId(roomUid);
         HashMap<String, Integer> sendMap = new HashMap<>();
         sendMap.put("userId", userId);
         message.setFromUserId(fromUserId.toString());
         message.setContent(sendMap);
         //发送消息
         try {
-            imFeignService.publishRoomMsg(message);
+            LivePluginService pluginService = livePluginContext.getPluginService(roomVo.getServiceProvider());
+            pluginService.sendChatRoomMessage(message);
             log.info("sendBlackMsg>>>> message: {}", JSONObject.toJSONString(message));
         } catch (Exception e) {
             log.error("sendBlackMsg>>>> error {}", e.getMessage());

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/ImLiveBroadcastRoomMapper.xml

@@ -92,6 +92,9 @@
             <if test="param.speakerId != null">
                 and  a.speaker_id_ = #{param.speakerId}
             </if>
+            <if test="param.serviceProvider != null and param.serviceProvider != ''">
+                and  a.service_provider_ = #{param.serviceProvider}
+            </if>
         </where>
     </select>