ソースを参照

直播请求接口参数改为imUserId

liujc 2 年 前
コミット
adebb5ee69

+ 9 - 2
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/open/ImController.java

@@ -155,6 +155,9 @@ public class ImController extends BaseController {
             log.debug("callbackOnMemberStateChange: {}", callbackOnMemberStateChange);
             callbackOnMemberStateChange.setClientIP(clientIP);
             callbackOnMemberStateChange.setOptPlatform(optPlatform);
+            for (TencentData.MemberListDTO memberListDTO : callbackOnMemberStateChange.getMemberList()) {
+                memberListDTO.setMemberAccount(imGroupService.analysisImUserId(memberListDTO.getMemberAccount()));
+            }
             // 直播间成员状态变更
             liveRoomService.callbackOnMemberStateChange(callbackOnMemberStateChange);
         } else if(request.getParameter("CallbackCommand").equals(ETencentImCallbackCommand.GROUP_CALLBACKAFTERMEMBEREXIT.getCommand())) {
@@ -165,7 +168,9 @@ public class ImController extends BaseController {
             log.debug("callbackAfterMemberExit: {}", callbackAfterMemberExit);
             callbackAfterMemberExit.setClientIP(clientIP);
             callbackAfterMemberExit.setOptPlatform(optPlatform);
-
+            for (TencentData.MemberListDTO memberListDTO : callbackAfterMemberExit.getExitMemberList()) {
+                memberListDTO.setMemberAccount(imGroupService.analysisImUserId(memberListDTO.getMemberAccount()));
+            }
             // 直播间成员状态变更
             liveRoomService.callbackAfterMemberExit(callbackAfterMemberExit);
         } else if(request.getParameter("CallbackCommand").equals(ETencentImCallbackCommand.GROUP_CALLBACKAFTERNEWMEMBERJOIN.getCommand())) {
@@ -176,7 +181,9 @@ public class ImController extends BaseController {
             log.debug("CallbackAfterNewMemberJoin: {}", callbackAfterNewMemberJoin);
             callbackAfterNewMemberJoin.setClientIP(clientIP);
             callbackAfterNewMemberJoin.setOptPlatform(optPlatform);
-
+            for (TencentData.MemberListDTO memberListDTO : callbackAfterNewMemberJoin.getNewMemberList()) {
+                memberListDTO.setMemberAccount(imGroupService.analysisImUserId(memberListDTO.getMemberAccount()));
+            }
             // 直播间成员状态变更
             liveRoomService.callbackAfterNewMemberJoin(callbackAfterNewMemberJoin);
         }

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

@@ -229,18 +229,20 @@ public class ImGroupServiceImpl extends ServiceImpl<ImGroupDao, ImGroup> impleme
      */
     @Override
     public String analysisImUserId(String imUserId) {
-        String[] s = imUserId.split("_");
-        if (s.length == 3) {
-            return s[1];
+        if (StringUtils.isNotBlank(imConfig.getAppPrefix()) && imUserId.startsWith(imConfig.getAppPrefix())) {
+            return imUserId.replace(imConfig.getAppPrefix() + "_", "").split("_")[0];
         }
         return imUserId;
     }
 
     @Override
     public String analysisImUserClient(String imUserId) {
-        String[] s = imUserId.split("_");
-        if (s.length == 3) {
-            return s[2];
+        if (StringUtils.isNotBlank(imConfig.getAppPrefix()) && imUserId.startsWith(imConfig.getAppPrefix())) {
+            imUserId =  imUserId.replace(imConfig.getAppPrefix() + "_", "");
+            String[] s = imUserId.split("_");
+            if (s.length > 1) {
+                return imUserId.replace(s[0] + "_", "");
+            }
         }
         return imUserId;
     }

+ 14 - 6
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/ImLiveBroadcastRoomController.java

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.student.controller;
 
 import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
+import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
 import com.yonge.cooleshow.biz.dal.wrapper.liveroom.LiveRoomWrapper;
 import com.yonge.cooleshow.common.controller.BaseController;
@@ -8,6 +9,7 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -29,6 +31,9 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @Resource
     private LiveRoomService liveRoomService;
 
+    @Autowired
+    private ImGroupService imGroupService;
+
     @ApiOperation("学生端-查询房间信息")
     @GetMapping("/queryRoomInfo")
     public HttpResponseResult<LiveRoomWrapper.LiveRoomVo> queryRoomInfo(@ApiParam(value = "房间uid", required = true) String roomUid) {
@@ -39,32 +44,35 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @ApiOperation("查询房间信息并校验房间是否合规")
     @GetMapping("/queryRoom")
     public HttpResponseResult<LiveRoomWrapper.LiveRoomVo> queryRoomAndCheck(@ApiParam(value = "房间uid", required = true) String roomUid,
-                                                                       @ApiParam(value = "用户id", required = true) Long userId) {
-        return succeed(liveRoomService.queryRoomAndCheck(roomUid, userId, 1));
+                                                                       @ApiParam(value = "用户id", required = true) String userId) {
+        return succeed(liveRoomService.queryRoomAndCheck(roomUid, Long.parseLong(imGroupService.analysisImUserId(userId)), 1));
     }
 
     @PostMapping("/quitRoom")
     public HttpResponseResult<Object> quitRoom(@RequestBody List<ImUserStateSync> userState) {
+        for (ImUserStateSync stateSync : userState) {
+            stateSync.setUserid(imGroupService.analysisImUserId(stateSync.getUserid()));
+        }
         liveRoomService.opsRoom(userState);
         return succeed();
     }
 
     @ApiOperation("学生-进入房间")
     @GetMapping("/joinRoom")
-    public HttpResponseResult<Object> joinRoom(String roomUid, Long userId,Boolean microphoneFlag) {
+    public HttpResponseResult<Object> joinRoom(String roomUid, String userId,Boolean microphoneFlag) {
         if (microphoneFlag == null) {
             microphoneFlag = true;
         }
-        liveRoomService.joinRoom(roomUid, userId,microphoneFlag);
+        liveRoomService.joinRoom(roomUid, Long.parseLong(imGroupService.analysisImUserId(userId)),microphoneFlag);
         return succeed();
     }
 
     @ApiOperation("设置连麦状态")
     @PutMapping("/userWhetherMic")
     public HttpResponseResult<Object> userWhetherMic(@ApiParam(value = "房间uid", required = true) String roomUid,
-                                                     @ApiParam(value = "用户id", required = true) Long userId,
+                                                     @ApiParam(value = "用户id", required = true) String userId,
                                                      @ApiParam(value = "连麦状态 0:未申请1:申请连麦中2:连麦中", required = true) Integer whetherMicStatus) {
-        liveRoomService.userWhetherMic(roomUid,userId,whetherMicStatus);
+        liveRoomService.userWhetherMic(roomUid,Long.parseLong(imGroupService.analysisImUserId(userId)),whetherMicStatus);
         return succeed();
     }
 }

+ 5 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherImLiveBroadcastRoomController.java

@@ -2,6 +2,7 @@ package com.yonge.cooleshow.teacher.controller;
 
 import com.microsvc.toolkit.middleware.live.message.TencentWrapper;
 import com.yonge.cooleshow.biz.dal.dto.LiveRoomStatus;
+import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.service.ImLiveBroadcastRoomMemberService;
 import com.yonge.cooleshow.biz.dal.service.LiveBroadcastRoomMemberService;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
@@ -39,6 +40,8 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
     @Autowired
     private ImLiveBroadcastRoomMemberService imLiveBroadcastRoomMemberService;
 
+    @Autowired
+    private ImGroupService imGroupService;
 
     @ApiOperation("查询房间信息并校验房间是否合规")
     @ApiImplicitParams({
@@ -99,9 +102,9 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
     @ApiOperation("设置连麦状态")
     @PutMapping("/userWhetherMic")
     public HttpResponseResult<Object> userWhetherMic(@ApiParam(value = "房间uid", required = true) String roomUid,
-                                                 @ApiParam(value = "用户id", required = true) Long userId,
+                                                 @ApiParam(value = "用户id", required = true) String userId,
                                                  @ApiParam(value = "连麦状态 0:未申请1:申请连麦中2:连麦中", required = true) Integer whetherMicStatus) {
-        liveRoomService.userWhetherMic(roomUid,userId,whetherMicStatus);
+        liveRoomService.userWhetherMic(roomUid,Long.parseLong(imGroupService.analysisImUserId(userId)),whetherMicStatus);
         return succeed();
     }