|
@@ -3,6 +3,7 @@ package com.ym.service.Impl;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ym.common.ApiException;
|
|
|
+import com.ym.common.BaseResponse;
|
|
|
import com.ym.common.DisplayEnum;
|
|
|
import com.ym.common.ErrorEnum;
|
|
|
import com.ym.config.IMProperties;
|
|
@@ -244,15 +245,36 @@ public class RoomServiceImpl implements RoomService {
|
|
|
return roomResult;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
@Override
|
|
|
- public void joinRoomSuccess(String roomId,String userId) throws Exception {
|
|
|
+ public void joinRoomFailure(String roomId, String userId) {
|
|
|
RoomMember roomMember = roomMemberDao.findByRidAndUid(roomId, userId);
|
|
|
if(roomMember == null){
|
|
|
return ;
|
|
|
}
|
|
|
+ log.info("joinRoomFailure : roomId={}, userId={}", roomId, userId);
|
|
|
+ //如果加入失败,删除该用户数据
|
|
|
+ roomMemberDao.deleteUserByRidAndUid(roomId,userId);
|
|
|
+ }
|
|
|
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
+ @Override
|
|
|
+ public void joinRoomSuccess(String roomId,String userId) throws Exception {
|
|
|
+ RoomMember roomMember = roomMemberDao.findByRidAndUid(roomId, userId);
|
|
|
+ if(roomMember == null){
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ String joinSuccessKey = "joinRoomSuccess"+ roomId + userId;
|
|
|
+ if(redisTemplate.hasKey(joinSuccessKey)){
|
|
|
+ //兼容旧版本,防止重复调用
|
|
|
+ redisTemplate.delete(joinSuccessKey);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ redisTemplate.opsForValue().set("joinRoomSuccess"+ roomId + userId,roomId);
|
|
|
log.info("joinRoomSuccess : roomId={}, userId={}", roomId, userId);
|
|
|
+
|
|
|
RoleEnum roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
|
|
|
CourseSchedule schedule = courseScheduleDao.getLock(Long.parseLong(roomId.substring(1)));
|
|
|
|
|
@@ -267,17 +289,16 @@ public class RoomServiceImpl implements RoomService {
|
|
|
Date curTime = DateTimeUtils.currentUTC();
|
|
|
Room room = roomDao.findByRid(roomId);
|
|
|
if (room == null) {
|
|
|
- //如果房间不存在,删除除了自己之外的其他用户
|
|
|
-// roomMemberDao.deleteRoomMember(roomId,userId);
|
|
|
saveRoom(roomId, roomId, curTime, display);
|
|
|
IMApiResultInfo resultInfo = imHelper.createGroup(new String[]{userId}, roomId, roomId);
|
|
|
if (!resultInfo.isSuccess()) {
|
|
|
log.error("joinRoomSuccess createGroup error: roomId={}, {}", roomId, resultInfo.getErrorMessage());
|
|
|
throw new ApiException(ErrorEnum.ERR_CREATE_ROOM_ERROR, resultInfo.getErrorMessage());
|
|
|
}
|
|
|
- }
|
|
|
- if(roleEnum == RoleTeacher || roleEnum == RoleEnum.RoleAssistant){
|
|
|
- updateDisplay(roomId, userId, display, 0);
|
|
|
+ }else{
|
|
|
+ if(roleEnum == RoleTeacher || roleEnum == RoleEnum.RoleAssistant){
|
|
|
+ updateDisplay(roomId, userId, display, 0);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
UserInfo userInfo = userDao.findByUid(userId);
|
|
@@ -360,6 +381,10 @@ public class RoomServiceImpl implements RoomService {
|
|
|
if(roomMember == null){
|
|
|
return ;
|
|
|
}
|
|
|
+ String joinSuccessKey = "joinRoomSuccess"+ roomId + userId;
|
|
|
+ if(redisTemplate.hasKey(joinSuccessKey)){
|
|
|
+ redisTemplate.delete(joinSuccessKey);
|
|
|
+ }
|
|
|
log.info("leaveRoomSuccess: roomId={}, userId={}", roomId,userId);
|
|
|
RoleEnum roleEnum = RoleEnum.getEnumByValue(roomMember.getRole());
|
|
|
Integer firstCourseId = Integer.parseInt(roomId.substring(1));
|