|
@@ -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);
|