|
@@ -39,6 +39,7 @@ 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;
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
import java.util.*;
|
|
@@ -150,6 +151,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
* @param dto 直播间信息
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void add(ImLiveBroadcastRoomDto dto) {
|
|
|
SysUser sysUser = getSysUser(dto.getSpeakerId());
|
|
|
ImLiveBroadcastRoom obj = new ImLiveBroadcastRoom();
|
|
@@ -173,6 +175,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
* @param dto
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void update(ImLiveBroadcastRoomDto dto) {
|
|
|
ImLiveBroadcastRoom obj = this.getById(dto.getId());
|
|
|
if (obj.getLiveState() == 1) {
|
|
@@ -188,11 +191,31 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 是否禁言
|
|
|
+ *
|
|
|
+ * @param id 房间id
|
|
|
+ * @param whetherChat 是否允许聊天互动 0允许 1不允许
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void whetherChat(Integer id, Integer whetherChat) {
|
|
|
+ ImLiveBroadcastRoom obj = this.getById(id);
|
|
|
+ ImLiveBroadcastRoomDto.RoomConfig roomConfig = getRoomConfig(obj.getRoomConfig()).orElse(null);
|
|
|
+ if (Objects.isNull(roomConfig)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ roomConfig.setWhether_chat(whetherChat);
|
|
|
+ obj.setRoomConfig(JSONObject.toJSONString(roomConfig));
|
|
|
+ this.updateById(obj);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 删除直播间
|
|
|
*
|
|
|
* @param id 直播间id
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void delete(Integer id) {
|
|
|
ImLiveBroadcastRoom obj = this.getById(id);
|
|
|
if (obj.getLiveState() == 1) {
|
|
@@ -620,8 +643,7 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
|
|
|
//查询房间信息是否允许录像
|
|
|
ImLiveBroadcastRoom one = this.getOne(new QueryWrapper<ImLiveBroadcastRoom>().eq("room_uid_", room.getRoomUid()));
|
|
|
- boolean video = Optional.ofNullable(one.getRoomConfig())
|
|
|
- .map(c -> JSON.parseObject(c, ImLiveBroadcastRoomDto.RoomConfig.class))
|
|
|
+ boolean video = getRoomConfig(one.getRoomConfig())
|
|
|
.filter(c -> Objects.nonNull(c.getWhether_video()))
|
|
|
.map(c -> c.getWhether_video() == 0)
|
|
|
.orElse(false);
|
|
@@ -651,6 +673,11 @@ public class ImLiveBroadcastRoomServiceImpl extends ServiceImpl<ImLiveBroadcastR
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private Optional<ImLiveBroadcastRoomDto.RoomConfig> getRoomConfig(String roomConfig) {
|
|
|
+ return Optional.ofNullable(roomConfig)
|
|
|
+ .map(c -> JSON.parseObject(c, ImLiveBroadcastRoomDto.RoomConfig.class));
|
|
|
+ }
|
|
|
+
|
|
|
private void getRoomData(ImLiveBroadcastRoomVo roomVo) {
|
|
|
//点赞数
|
|
|
Object like = redissonClient.getBucket(LIVE_ROOM_LIKE.replace(ROOM_UID, roomVo.getRoomUid())).get();
|