|
@@ -1,7 +1,6 @@
|
|
|
package com.ym.service.Impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.ym.common.ApiException;
|
|
@@ -247,10 +246,10 @@ public class RoomServiceImpl implements RoomService {
|
|
|
userResult.setHandUpOn(member.isHand());
|
|
|
userResult.setJoinTime(member.getJoinDt());
|
|
|
}
|
|
|
- imHelper.joinGroup(new String[]{userId}, roomId, roomId);
|
|
|
+// imHelper.joinGroup(new String[]{userId}, roomId, roomId);
|
|
|
+ this.joinImGroup(roomId,schedule.getActualTeacherId());
|
|
|
|
|
|
List<CourseScheduleStudentMusicScore> scheduleStudentMusicScores = courseScheduleStudentMusicScoreDao.queryByScoreIdAndCourseId(null, courseId, null, null, null);
|
|
|
-
|
|
|
Room room = roomDao.findByRid(roomId);
|
|
|
String display = "";
|
|
|
if (roleEnum == RoleTeacher) {
|
|
@@ -287,8 +286,6 @@ public class RoomServiceImpl implements RoomService {
|
|
|
userResult.setPlayMidiJson(JSONObject.parseObject(midi, CustomMessage.class));
|
|
|
|
|
|
//获取当前课程剩余时长
|
|
|
-// String classDate = DateUtil.format(courseSchedule.getClassDate(), DateUtil.DEFAULT_PATTERN);
|
|
|
-// String endClassTime = DateUtil.format(courseSchedule.getEndClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
|
|
|
roomResult.setSurplusTime(DateUtil.secondsBetween(new Date(), courseSchedule.getEndClassTime()));
|
|
|
|
|
|
roomResult.setUserInfo(userResult);
|
|
@@ -323,6 +320,23 @@ public class RoomServiceImpl implements RoomService {
|
|
|
return new BaseResponse(roomResult);
|
|
|
}
|
|
|
|
|
|
+ private void joinImGroup(String roomId,Integer actualTeacherId) throws Exception {
|
|
|
+ String joinImGroupKey = "joinImGroup:" + roomId;
|
|
|
+ Boolean aBoolean = redisTemplate.opsForValue().setIfAbsent(joinImGroupKey, roomId, 1l, TimeUnit.DAYS);
|
|
|
+ if (aBoolean) {
|
|
|
+ List<CourseScheduleStudentPayment> payments = courseScheduleStudentPaymentDao.findByCourseSchedule(Long.parseLong(roomId.substring(1)));
|
|
|
+ List<String> collect = payments.stream().map(e -> e.getUserId().toString()).collect(Collectors.toList());
|
|
|
+ collect.add(actualTeacherId.toString());
|
|
|
+ String[] integers = collect.toArray(new String[]{});
|
|
|
+ imHelper.joinGroup(integers, roomId, roomId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void dismissImGroup(String userId,String roomId) throws Exception {
|
|
|
+ String joinImGroupKey = "joinImGroup:" + roomId;
|
|
|
+ redisTemplate.delete(joinImGroupKey);
|
|
|
+ imHelper.dismiss(userId, roomId);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public RoomMember saveRoomMember(String roomId, String userId) {
|
|
|
SysUser sysUser = sysUserFeignService.queryUserById(Integer.parseInt(userId));
|
|
@@ -395,11 +409,7 @@ public class RoomServiceImpl implements RoomService {
|
|
|
Room room = roomDao.findByRid(roomId);
|
|
|
if (room == null) {
|
|
|
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());
|
|
|
- }
|
|
|
+ this.joinImGroup(roomId,schedule.getActualTeacherId());
|
|
|
} else {
|
|
|
if (roleEnum == RoleTeacher || roleEnum == RoleEnum.RoleAssistant) {
|
|
|
updateDisplay(roomId, userId, display, 0);
|
|
@@ -547,7 +557,7 @@ public class RoomServiceImpl implements RoomService {
|
|
|
roomMemberDao.deleteUserByRidAndUid(roomId, userId);
|
|
|
roomDao.deleteByRid(roomId);
|
|
|
deleteWhiteboardByUser(roomId, userId);
|
|
|
- imHelper.dismiss(userId, roomId);
|
|
|
+ this.dismissImGroup(userId, roomId);
|
|
|
courseScheduleStudentMusicScoreDao.closePlayStatus(courseSchedule.getId(), null, null);
|
|
|
log.info("leaveRoomSuccess dismiss the room: {},userId: {}", roomId, userId);
|
|
|
} else {
|
|
@@ -555,7 +565,7 @@ public class RoomServiceImpl implements RoomService {
|
|
|
MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, userId, roleEnum.getValue());
|
|
|
msg.setUserName(username);
|
|
|
imHelper.publishMessage(userId, roomId, msg);
|
|
|
- imHelper.quit(new String[]{userId}, roomId);
|
|
|
+// imHelper.quit(new String[]{userId}, roomId);
|
|
|
log.info("leaveRoomSuccess quit group: roomId={},userId: {}", roomId, userId);
|
|
|
}
|
|
|
userDao.deleteByUid(userId);
|
|
@@ -580,7 +590,7 @@ public class RoomServiceImpl implements RoomService {
|
|
|
List<RoomMember> list = roomMemberDao.findByRid(roomId);
|
|
|
if (!list.isEmpty()) {
|
|
|
try {
|
|
|
- imHelper.dismiss(list.get(0).getUid(), roomId);
|
|
|
+ this.dismissImGroup(list.get(0).getUid(), roomId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("destroyRoom: {}", e.getMessage());
|
|
|
e.printStackTrace();
|
|
@@ -669,10 +679,10 @@ public class RoomServiceImpl implements RoomService {
|
|
|
roomMemberDao.deleteUserByRidAndUid(roomId, userId);
|
|
|
userDao.deleteByUid(userId);
|
|
|
|
|
|
- IMApiResultInfo apiResultInfo = imHelper.quit(new String[]{userId}, roomId);
|
|
|
- if (!apiResultInfo.isSuccess()) {
|
|
|
- throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
|
|
|
- }
|
|
|
+// IMApiResultInfo apiResultInfo = imHelper.quit(new String[]{userId}, roomId);
|
|
|
+// if (!apiResultInfo.isSuccess()) {
|
|
|
+// throw new ApiException(ErrorEnum.ERR_EXIT_ROOM_ERROR, apiResultInfo.getErrorMessage());
|
|
|
+// }
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -1523,29 +1533,16 @@ public class RoomServiceImpl implements RoomService {
|
|
|
}
|
|
|
}
|
|
|
if (roomMemberDao.countByRid(member.getRid()) == 1) {
|
|
|
- IMApiResultInfo apiResultInfo = null;
|
|
|
- apiResultInfo = imHelper.dismiss(member.getUid(), member.getRid());
|
|
|
- if (apiResultInfo.getCode() == 200) {
|
|
|
- roomMemberDao.deleteUserByRidAndUid(member.getRid(), member.getUid());
|
|
|
- roomDao.deleteByRid(member.getRid());
|
|
|
- deleteWhiteboardByUser(member.getRid(), member.getUid());
|
|
|
- log.info("dismiss the room: {},userId: {}", member.getRid(), userId);
|
|
|
- } else {
|
|
|
- log.error("{} exit {} room error: {}", member.getUid(), member.getRid(), apiResultInfo.getErrorMessage());
|
|
|
- }
|
|
|
+ this.dismissImGroup(member.getUid(), member.getRid());
|
|
|
+ roomMemberDao.deleteUserByRidAndUid(member.getRid(), member.getUid());
|
|
|
+ roomDao.deleteByRid(member.getRid());
|
|
|
+ deleteWhiteboardByUser(member.getRid(), member.getUid());
|
|
|
+ log.info("dismiss the room: {},userId: {}", member.getRid(), userId);
|
|
|
} else {
|
|
|
- IMApiResultInfo apiResultInfo = null;
|
|
|
- apiResultInfo = imHelper.quit(new String[]{member.getUid()}, member.getRid());
|
|
|
- if (apiResultInfo.isSuccess()) {
|
|
|
- roomMemberDao.deleteUserByRidAndUid(member.getRid(), member.getUid());
|
|
|
- MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, member.getUid(), userRole);
|
|
|
- msg.setUserName(member.getName());
|
|
|
- imHelper.publishMessage(member.getUid(), member.getRid(), msg);
|
|
|
- imHelper.quit(new String[]{member.getUid()}, member.getRid());
|
|
|
- log.info("quit group: roomId={},userId: {}", member.getRid(), member.getUid());
|
|
|
- } else {
|
|
|
- log.error("{} exit {} room error: {}", member.getUid(), member.getRid(), apiResultInfo.getErrorMessage());
|
|
|
- }
|
|
|
+ roomMemberDao.deleteUserByRidAndUid(member.getRid(), member.getUid());
|
|
|
+ MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Action_Leave, member.getUid(), userRole);
|
|
|
+ msg.setUserName(member.getName());
|
|
|
+ imHelper.publishMessage(member.getUid(), member.getRid(), msg);
|
|
|
}
|
|
|
userDao.deleteByUid(member.getUid());
|
|
|
} catch (Exception e) {
|