Bladeren bron

增加回放查询 及 临时直播间列表查询

hgw 3 jaren geleden
bovenliggende
commit
b30e049be9

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/entity/LiveRoomVideo.java

@@ -51,7 +51,7 @@ public class LiveRoomVideo implements Serializable {
     private Date endTime;
 
     @TableField("type")
-    @ApiModelProperty(value = "1: 录制开始;2: 录制切片;3: 录制结束;4: 文件上传-融云回调完成;0开始录制  1录制结束 2融云回调完成")
+    @ApiModelProperty(value = "1: 录制开始;2: 录制切片;3: 录制结束;4: 文件上传-融云回调完成")
     private Integer type;
 
     @TableField("created_time_")

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

@@ -42,13 +42,7 @@ public enum CourseScheduleEnum implements BaseEnum<String, CourseScheduleEnum> {
         CourseScheduleEnum[] values = {PRACTICE, LIVE, PIANO_ROOM_CLASS};
         existCourse(values, code, errMsg);
         //返回枚举对象
-        if (code.equals(CourseScheduleEnum.PRACTICE.getCode())) {
-            return CourseScheduleEnum.PRACTICE;
-        } else if (code.equals(CourseScheduleEnum.LIVE.getCode())) {
-            return CourseScheduleEnum.LIVE;
-        } else {
-            return CourseScheduleEnum.PIANO_ROOM_CLASS;
-        }
+        return CourseScheduleEnum.valueOf(code);
     }
 
     /**

+ 11 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomService.java

@@ -2,9 +2,11 @@ package com.yonge.cooleshow.biz.dal.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
-import com.yonge.cooleshow.biz.dal.entity.*;
-import com.yonge.cooleshow.biz.dal.vo.RoomVo;
-import org.springframework.transaction.annotation.Transactional;
+import com.yonge.cooleshow.biz.dal.entity.ImRoomMessage;
+import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoom;
+import com.yonge.cooleshow.biz.dal.entity.RoomInfoCache;
+import com.yonge.toolset.base.page.PageInfo;
 
 import java.util.List;
 import java.util.Map;
@@ -20,11 +22,14 @@ public interface LiveRoomService extends IService<LiveRoom> {
     LiveRoomDao getDao();
 
     /**
-     * 根据房间uid查询房间信息
+     * 分页查询当前用户关联的房间信息
      *
-     * @param roomUid 房间uid
+     * @param param 参数
+     *              <p>roomType 房间类型  LIVE-直播课  TEMP-临时直播间
+     *              <p>page 页数
+     *              <p>rows 每页数量
      */
-    RoomVo queryRoomInfo(String roomUid);
+    PageInfo<LiveRoom> queryPageRoom(Map<String, Object> param);
 
     /**
      * 校验房间信息,及个人信息

+ 9 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/LiveRoomVideoService.java

@@ -5,6 +5,8 @@ import com.yonge.cooleshow.biz.dal.dao.LiveRoomVideoDao;
 import com.yonge.cooleshow.biz.dal.entity.LiveRoomVideo;
 import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
 
+import java.util.List;
+
 /**
  * 直播视频记录(LiveRoomVideo)表服务接口
  *
@@ -15,6 +17,13 @@ public interface LiveRoomVideoService extends IService<LiveRoomVideo> {
 
     LiveRoomVideoDao getDao();
 
+    /**
+     * 查询对应房间的录像
+     *
+     * @param roomUid 房间uid
+     */
+    List<LiveRoomVideo> queryVideo(String roomUid);
+
     void recordSync(RecordNotify recordNotify);
 }
 

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

@@ -1,7 +1,9 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 import com.alibaba.fastjson.JSONObject;
+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.beust.jcommander.internal.Lists;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
@@ -13,9 +15,10 @@ import com.yonge.cooleshow.biz.dal.enums.*;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.support.IMHelper;
 import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
-import com.yonge.cooleshow.biz.dal.vo.RoomVo;
 import com.yonge.cooleshow.biz.dal.vo.UserOrderVo;
 import com.yonge.toolset.base.exception.BizException;
+import com.yonge.toolset.base.page.PageInfo;
+import com.yonge.toolset.mybatis.support.PageUtil;
 import com.yonge.toolset.utils.date.DateUtil;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -24,7 +27,6 @@ import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -88,23 +90,23 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     }
 
     /**
-     * 根据房间uid查询房间信息
+     * 分页查询当前用户关联的房间信息
      *
-     * @param roomUid 房间uid
+     * @param param 参数
+     *              <p>roomType 房间类型  LIVE-直播课  TEMP-临时直播间
+     *              <p>page 页数
+     *              <p>rows 每页数量
      */
     @Override
-    public RoomVo queryRoomInfo(String roomUid) {
-        LiveRoom liveRoom = this.getOne(Wrappers.<LiveRoom>lambdaQuery()
-                .eq(LiveRoom::getRoomUid, roomUid));
-        if (liveRoom == null) {
-            throw new BizException("房间不存在");
-        }
-        RoomVo roomVo = new RoomVo();
-        BeanUtils.copyProperties(liveRoom, roomVo);
-        roomVo.setSpeakerName(getSysUser(liveRoom.getSpeakerId()).getRealName());
-        roomVo.setLikeNum(getLike(roomUid));
-        roomVo.setLookNum(getNum.apply(this::getOnlineUserCache, roomUid));
-        return roomVo;
+    public PageInfo<LiveRoom> queryPageRoom(Map<String, Object> param) {
+        String roomType = WrapperUtil.toStr(param, "roomType");
+        Long userId = getSysUser().getId();
+        Page<LiveRoom> pageInfo = PageUtil.getPageInfo(param);
+        IPage<LiveRoom> page = this.page(pageInfo, Wrappers.<LiveRoom>lambdaQuery()
+                .eq(WrapperUtil.StrPredicate.test(roomType), LiveRoom::getType, roomType)
+                .eq(LiveRoom::getSpeakerId, userId)
+        );
+        return PageUtil.pageInfo(page);
     }
 
     /**
@@ -210,12 +212,21 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     public String createTempLiveRoom(Map<String, Object> param) {
         //查询主讲人信息
         SysUser sysUser = getSysUser();
+        Long teacherId = sysUser.getId();
+        List<LiveRoom> liveRoomList = this.list(Wrappers.<LiveRoom>lambdaQuery()
+                .eq(LiveRoom::getSpeakerId, teacherId)
+                .eq(LiveRoom::getType, RoomTypeEnum.TEMP.getCode())
+                .eq(LiveRoom::getLiveState, 1)
+                .eq(LiveRoom::getRoomState, 0)
+        );
+        if (CollectionUtils.isNotEmpty(liveRoomList)) {
+            throw new BizException("当前有直播间未结束,无需创建直播!");
+        }
         String roomTitle = WrapperUtil.toStr(param, "roomTitle", "房间标题不能为空!");
         String liveRemark = WrapperUtil.toStr(param, "liveRemark", "直播间描述不能为空!");
         Integer liveTime = WrapperUtil.toInt(param, "liveTime", "请选择直播时长!");
         Date liveStartTime = new Date();
         Date liveEndTime = DateUtil.addMinutes(liveStartTime, liveTime);
-        Long teacherId = sysUser.getId();
         //当前时间有课程则不能开启直播
         boolean check = courseScheduleService.checkTeacherCourseTime(teacherId, liveStartTime, liveEndTime);
         if (check) {
@@ -233,7 +244,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         room.setSpeakerId(teacherId);
         room.setLiveStartTime(liveStartTime);
         room.setLiveEndTime(liveEndTime);
-        room.setLiveState(0);
+        room.setLiveState(1);
         room.setRoomState(0);
         room.setCreatedBy(teacherId);
         room.setCreatedTime(liveStartTime);

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

@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.Date;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -36,6 +37,19 @@ public class LiveRoomVideoServiceImpl extends ServiceImpl<LiveRoomVideoDao, Live
         return this.baseMapper;
     }
 
+    /**
+     * 查询对应房间的录像
+     *
+     * @param roomUid 房间uid
+     */
+    @Override
+    public List<LiveRoomVideo> queryVideo(String roomUid) {
+        return this.list(Wrappers.<LiveRoomVideo>lambdaQuery()
+                .eq(LiveRoomVideo::getRoomUid, roomUid)
+                .eq(LiveRoomVideo::getType, 4)
+        );
+    }
+
     @Override
     public void recordSync(RecordNotify recordNotify) {
         if (recordNotify.getCode().equals(200)) {

+ 13 - 1
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomController.java

@@ -1,12 +1,13 @@
 package com.yonge.cooleshow.teacher.controller;
 
-
 import com.alibaba.fastjson.JSONObject;
 import com.yonge.cooleshow.biz.dal.entity.ImUserStateSync;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoom;
 import com.yonge.cooleshow.biz.dal.entity.RoomInfoCache;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomService;
 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,6 +34,17 @@ public class TeacherLiveRoomController extends BaseController {
     @Resource
     private LiveRoomService liveRoomService;
 
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "roomType", dataType = "String", value = "房间类型  LIVE-直播课  TEMP-临时直播间"),
+            @ApiImplicitParam(name = "page", dataType = "Integer", value = "页数"),
+            @ApiImplicitParam(name = "rows", dataType = "Integer", value = "每页数量"),
+    })
+    @ApiOperation("分页查询当前用户关联的房间信息")
+    @PostMapping("/queryPageRoom")
+    public HttpResponseResult<PageInfo<LiveRoom>> queryPageRoom(@RequestBody Map<String, Object> param) {
+        return succeed(liveRoomService.queryPageRoom(param));
+    }
+
     /**
      * 根据房间uid查询房间信息
      *

+ 56 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherLiveRoomVideoController.java

@@ -0,0 +1,56 @@
+package com.yonge.cooleshow.teacher.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoomVideo;
+import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
+import com.yonge.cooleshow.biz.dal.service.LiveRoomVideoService;
+import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * 直播视频记录(LiveRoomVideo)表控制层
+ *
+ * @author hgw
+ * @since 2022-03-18 15:41:17
+ */
+@Api(tags = "直播视频记录")
+@RestController
+@RequestMapping("/liveRoomVideo")
+public class TeacherLiveRoomVideoController extends BaseController {
+
+    private final static Logger log = LoggerFactory.getLogger(TeacherLiveRoomVideoController.class);
+
+    /**
+     * 服务对象
+     */
+    @Resource
+    private LiveRoomVideoService liveRoomVideoService;
+
+    @ApiOperation("查询直播回放")
+    @GetMapping("/queryVideo")
+    public HttpResponseResult<List<LiveRoomVideo>> queryVideo(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        return succeed(liveRoomVideoService.queryVideo(roomUid));
+    }
+
+    @ApiOperation("录制结果回调")
+    @RequestMapping(value = "/recordSync")
+    public void recordSync(@RequestBody String body) {
+        log.info("recordSync body:{}", body);
+        RecordNotify recordNotify = JSONObject.parseObject(body, RecordNotify.class);
+        liveRoomVideoService.recordSync(recordNotify);
+    }
+
+}
+

+ 12 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/LiveRoomVideoController.java → cooleshow-user/user-website/src/main/java/com/yonge/cooleshow/website/controller/LiveRoomVideoController.java

@@ -1,19 +1,23 @@
-package com.yonge.cooleshow.teacher.controller;
-
+package com.yonge.cooleshow.website.controller;
 
 import com.alibaba.fastjson.JSONObject;
+import com.yonge.cooleshow.biz.dal.entity.LiveRoomVideo;
 import com.yonge.cooleshow.biz.dal.entity.RecordNotify;
 import com.yonge.cooleshow.biz.dal.service.LiveRoomVideoService;
 import com.yonge.cooleshow.common.controller.BaseController;
+import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * 直播视频记录(LiveRoomVideo)表控制层
@@ -34,6 +38,12 @@ public class LiveRoomVideoController extends BaseController {
     @Resource
     private LiveRoomVideoService liveRoomVideoService;
 
+    @ApiOperation("查询直播回放")
+    @GetMapping("/queryVideo")
+    public HttpResponseResult<List<LiveRoomVideo>> queryVideo(@ApiParam(value = "房间uid", required = true) String roomUid) {
+        return succeed(liveRoomVideoService.queryVideo(roomUid));
+    }
+
     @ApiOperation("录制结果回调")
     @RequestMapping(value = "/recordSync")
     public void recordSync(@RequestBody String body) {