瀏覽代碼

直播ImUserId

liujc 2 年之前
父節點
當前提交
4ede13b371

+ 16 - 3
cooleshow-user/user-student/src/main/java/com/yonge/cooleshow/student/controller/ImLiveBroadcastRoomController.java

@@ -9,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.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -45,7 +46,11 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @GetMapping("/queryRoom")
     public HttpResponseResult<LiveRoomWrapper.LiveRoomVo> queryRoomAndCheck(@ApiParam(value = "房间uid", required = true) String roomUid,
                                                                        @ApiParam(value = "用户id", required = true) String userId) {
-        return succeed(liveRoomService.queryRoomAndCheck(roomUid, Long.parseLong(imGroupService.analysisImUserId(userId)), 1));
+        Long userIdLong = null;
+        if (StringUtils.isNotBlank(userId)) {
+            userIdLong = Long.parseLong(imGroupService.analysisImUserId(userId));
+        }
+        return succeed(liveRoomService.queryRoomAndCheck(roomUid, userIdLong, 1));
     }
 
     @PostMapping("/quitRoom")
@@ -63,7 +68,11 @@ public class ImLiveBroadcastRoomController extends BaseController {
         if (microphoneFlag == null) {
             microphoneFlag = true;
         }
-        liveRoomService.joinRoom(roomUid, Long.parseLong(imGroupService.analysisImUserId(userId)),microphoneFlag);
+        Long userIdLong = null;
+        if (StringUtils.isNotBlank(userId)) {
+            userIdLong = Long.parseLong(imGroupService.analysisImUserId(userId));
+        }
+        liveRoomService.joinRoom(roomUid, userIdLong,microphoneFlag);
         return succeed();
     }
 
@@ -72,7 +81,11 @@ public class ImLiveBroadcastRoomController extends BaseController {
     public HttpResponseResult<Object> userWhetherMic(@ApiParam(value = "房间uid", required = true) String roomUid,
                                                      @ApiParam(value = "用户id", required = true) String userId,
                                                      @ApiParam(value = "连麦状态 0:未申请1:申请连麦中2:连麦中", required = true) Integer whetherMicStatus) {
-        liveRoomService.userWhetherMic(roomUid,Long.parseLong(imGroupService.analysisImUserId(userId)),whetherMicStatus);
+        Long userIdLong = null;
+        if (StringUtils.isNotBlank(userId)) {
+            userIdLong = Long.parseLong(imGroupService.analysisImUserId(userId));
+        }
+        liveRoomService.userWhetherMic(roomUid,userIdLong,whetherMicStatus);
         return succeed();
     }
 }

+ 6 - 1
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherImLiveBroadcastRoomController.java

@@ -12,6 +12,7 @@ import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.page.PageInfo;
 import io.swagger.annotations.*;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
@@ -104,7 +105,11 @@ public class TeacherImLiveBroadcastRoomController extends BaseController {
     public HttpResponseResult<Object> userWhetherMic(@ApiParam(value = "房间uid", required = true) String roomUid,
                                                  @ApiParam(value = "用户id", required = true) String userId,
                                                  @ApiParam(value = "连麦状态 0:未申请1:申请连麦中2:连麦中", required = true) Integer whetherMicStatus) {
-        liveRoomService.userWhetherMic(roomUid,Long.parseLong(imGroupService.analysisImUserId(userId)),whetherMicStatus);
+        Long userIdLong = null;
+        if (StringUtils.isNotBlank(userId)) {
+            userIdLong = Long.parseLong(imGroupService.analysisImUserId(userId));
+        }
+        liveRoomService.userWhetherMic(roomUid,userIdLong,whetherMicStatus);
         return succeed();
     }