Procházet zdrojové kódy

Merge branch 'feature/0803-im' of http://git.dayaedu.com/yonge/cooleshow into feature/0803-im

zouxuan před 2 roky
rodič
revize
8bf5edb663

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/RoomTypeEnum.java

@@ -8,7 +8,7 @@ public enum RoomTypeEnum {
 
     LIVE("直播课"),
     PRACTICE("陪练课"),
-    LIVE_TEMP("临时直播间");
+    TEMP("临时直播间");
 
     private final String code;
 

+ 5 - 5
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -146,7 +146,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
      * <p> en :房间类型
      */
     private final BiFunction<Long, RoomTypeEnum, String> GenRoomUid = (userId, en) -> String
-            .join("-", en.getCode(), userId.toString(), new Date().getTime() + "");
+            .join("-", en.equals(RoomTypeEnum.TEMP)?RoomTypeEnum.LIVE.getCode() +"_"+en.getCode():en.getCode(), userId.toString(), new Date().getTime() + "");
 
     @Override
     public LiveRoomDao getDao() {
@@ -405,7 +405,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         Long teacherId = sysUser.getId();
         List<LiveRoom> liveRoomList = this.list(Wrappers.<LiveRoom>lambdaQuery()
                 .eq(LiveRoom::getSpeakerId, teacherId)
-                .eq(LiveRoom::getType, RoomTypeEnum.LIVE_TEMP.getCode())
+                .eq(LiveRoom::getType, RoomTypeEnum.TEMP.getCode())
                 .eq(LiveRoom::getLiveState, 1)
                 .eq(LiveRoom::getRoomState, 0)
         );
@@ -427,7 +427,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
             //如果当前时间和课程时间有交集则不能开启临时直播
             throw new BizException("当前选择的时间段有课无法开启直播");
         }
-        RoomTypeEnum en = RoomTypeEnum.LIVE_TEMP;
+        RoomTypeEnum en = RoomTypeEnum.TEMP;
         String roomUid = GenRoomUid.apply(teacherId, en);
         LiveRoom room = new LiveRoom();
         room.setRoomUid(roomUid);
@@ -1072,7 +1072,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
 
         CourseSchedule schedule = getCourseScheduleByRoomUid(roomUid);
         //校验观看者是否买过课,如果是非临时直播间,则校验是否已经买过课
-        if (!roomInfo.getRoomType().equals(RoomTypeEnum.LIVE_TEMP.getCode())) {
+        if (!roomInfo.getRoomType().equals(RoomTypeEnum.TEMP.getCode())) {
             // 查询该学员成功购买课程
             CourseScheduleStudentPayment studentPayment = courseScheduleStudentPaymentService.getOne(Wrappers.<CourseScheduleStudentPayment>lambdaQuery()
                     .eq(CourseScheduleStudentPayment::getUserId, sysUser.getId())
@@ -2278,7 +2278,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         }
         RoomSpeakerInfo roomSpeakerInfo = speakerCache.get();
         //已是直播状态则直接返回
-        if (roomSpeakerInfo !=null && roomSpeakerInfo.getState() ==  0) {
+        if (roomSpeakerInfo !=null &&roomSpeakerInfo.getState() !=null && roomSpeakerInfo.getState() ==  0) {
             return;
         }
 

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/wrapper/course/CourseScheduleWrapper.java

@@ -19,7 +19,7 @@ public class CourseScheduleWrapper {
         @ApiModelProperty(value = "声部ID")
         private String subjectId;
         @ApiModelProperty(value ="直播延长时间")
-        private String autoCloseNetworkRoomTime;
+        private String autoCloseNetworkRoomTime = "0";
         @ApiModelProperty("服务器时间 毫秒")
         private long timestamp;
 

+ 6 - 0
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.alibaba.fastjson.JSONObject;
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
 import com.yonge.cooleshow.biz.dal.service.ImGroupService;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
@@ -36,6 +37,9 @@ public class ImLiveBroadcastRoomController extends BaseController {
     @Autowired
     private ImGroupService imGroupService;
 
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+
     @ApiOperation("学生端-查询房间信息")
     @GetMapping("/queryRoomInfo")
     public HttpResponseResult<LiveRoomWrapper.LiveRoomVo> queryRoomInfo(@ApiParam(value = "房间uid", required = true) String roomUid) {
@@ -72,6 +76,8 @@ public class ImLiveBroadcastRoomController extends BaseController {
         Long userIdLong = null;
         if (StringUtils.isNotBlank(userId)) {
             userIdLong = Long.parseLong(imGroupService.analysisImUserId(userId));
+        } else {
+            userIdLong =sysUserFeignService.queryUserInfo().getId();
         }
         liveRoomService.joinRoom(roomUid, userIdLong,microphoneFlag);
         return succeed();