Skip to content

Commit

Permalink
feat: service 성능 테스트 메서드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
smartandhandsome committed Dec 22, 2023
1 parent b81781e commit 62b15de
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,29 @@ private void backUpChattingRoom(List<ChattingMessage> allMessages, List<User> us
users.stream().map(user -> new UserChattingHistory(user, chattingRoomHistory)).toList());
}

@Transactional
public void deleteChattingRoom2(Long roomId) {
ChattingRoom chattingRoom = chattingRoomQuery.getChattingRoomById(roomId);
List<User> users = userQuery.getUsersByRoom(chattingRoom);
List<ChattingMessage> allMessages = chattingMessageQuery.findAllMessages(chattingRoom);
backUpChattingRoom2(allMessages, users, chattingRoom);
chattingRoomCommand.removeChattingRoom(chattingRoom);
sendChattingEndAlarm(users);
updateUserStatusToIdle(users);
}

private void backUpChattingRoom2(List<ChattingMessage> allMessages, List<User> users,
ChattingRoom chattingRoom) {
ChattingRoomHistory chattingRoomHistory = chattingRoomHistoryCommand.createChattingRoomHistory(
chattingRoom);
chattingMessageHistoryCommand.createChattingMessageHistoryBatch(allMessages.stream().map(
chattingMessage -> new ChattingMessageHistory(chattingMessage.getMessage(),
chattingRoomHistory, chattingMessage.getCreatedAt(), chattingMessage.getUser()))
.toList());
userChattingHistoryCommand.createUserChattingHistory(
users.stream().map(user -> new UserChattingHistory(user, chattingRoomHistory)).toList());
}

private void updateUserStatusToIdle(List<User> users) {
users.forEach(User::setIdleStatus);
}
Expand Down

0 comments on commit 62b15de

Please sign in to comment.