Browse Source

优化 直播课录制视频的逻辑

hgw 3 years ago
parent
commit
6f35e35b97

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

@@ -1,6 +1,7 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomVideoDao;
 import com.yonge.cooleshow.biz.dal.entity.LiveRoom;
@@ -48,16 +49,13 @@ public class LiveRoomVideoServiceImpl extends ServiceImpl<LiveRoomVideoDao, Live
             Integer notifyType = recordNotify.getType();
             if (Objects.nonNull(notifyType)) {
                 Date now = new Date();
-                LiveRoomVideo video = this.getOne(new QueryWrapper<LiveRoomVideo>().lambda()
-                        .eq(LiveRoomVideo::getRoomUid, roomUid)
-                        .eq(LiveRoomVideo::getRecordId, recordId));
                 //notifyType 1: 录制开始;4: 文件上传-融云回调完成
                 if (notifyType == 1) {
-                    video = new LiveRoomVideo();
+                    LiveRoomVideo video = new LiveRoomVideo();
                     LiveRoom room = liveRoomService.getOne(new QueryWrapper<LiveRoom>().lambda()
                             .eq(LiveRoom::getRoomUid, roomUid));
                     video.setCourseGroupId(room.getCourseGroupId());
-                    video.setCourseId(room.getId());
+                    video.setCourseId(room.getCourseId());
                     video.setRoomUid(roomUid);
                     video.setRecordId(recordId);
                     video.setUrl(fileUrl);
@@ -67,11 +65,13 @@ public class LiveRoomVideoServiceImpl extends ServiceImpl<LiveRoomVideoDao, Live
                     this.save(video);
                 }
                 if (notifyType == 4) {
+                    LiveRoomVideo video = this.getOne(Wrappers.<LiveRoomVideo>lambdaQuery()
+                            .eq(LiveRoomVideo::getRoomUid, roomUid)
+                            .eq(LiveRoomVideo::getRecordId, recordId));
                     video.setEndTime(now);
                     video.setType(notifyType);
                     this.updateById(video);
                 }
-
             }
         }
     }