Skip to content

Commit

Permalink
refactor: 변수명 변경 (firstMessageId -> lastMessageId)
Browse files Browse the repository at this point in the history
  • Loading branch information
smartandhandsome committed Jan 6, 2024
1 parent 3260ac8 commit c4887c4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public ChattingRoomHistory backUpChattingRoom(ChattingRoom chattingRoom,
return chattingRoomHistory;
}

public void migrateChattingMessagesToHistoryInChattingRoom(ChattingRoom chattingRoom,
ChattingRoomHistory chattingRoomHistory, Long firstMessageId) {
Long messageId = firstMessageId;
public void migrateChattingMessagesToHistoryInChattingRoom(final ChattingRoom chattingRoom,
final ChattingRoomHistory chattingRoomHistory, final Long chattingRoomLastMessageId) {
Long messageId = chattingRoomLastMessageId;
while (true) {
List<ChattingMessage> messages = chattingMessageQuery.getChattingMessagesLessThanOrEqualToMessageId(
chattingRoom, messageId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public class ChattingRoomController {
public ResponseEntity<ChattingCustomSlice.Response> viewChattingRoomMessages(
@Login AuthInfo authInfo,
@PathVariable Long roomId,
@RequestParam Long firstMessageId,
@RequestParam Long lastMessageId,
@RequestParam(defaultValue = "50") int pageSize) {
ChattingListDto responses = chattingRoomService.searchMessages(authInfo.userId(), roomId,
firstMessageId,
lastMessageId,
pageSize);
return ResponseEntity.ok(ChattingCustomSlice.Response.from(responses));
}
Expand All @@ -39,9 +39,9 @@ public ResponseEntity<ChattingCustomSlice.Response> viewChattingRoomMessages(
public ResponseEntity<Void> exitChattingRoom(
@Login AuthInfo authInfo,
@PathVariable Long roomId,
@RequestParam Long firstMessageId
@RequestParam Long chattingRoomLastMessageId
) {
chattingRoomService.exitChattingRoom(authInfo.userId(), roomId, firstMessageId);
chattingRoomService.exitChattingRoom(authInfo.userId(), roomId, chattingRoomLastMessageId);
return ResponseEntity.ok().build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public Long createChattingRoom() {
}

@Transactional
public ChattingListDto searchMessages(Long requestedUserId, Long roomId, Long firstMessageId,
public ChattingListDto searchMessages(Long requestedUserId, Long roomId, Long lastMessageId,
int pageSize) {
ChattingRoom chattingRoom = chattingRoomQuery.getChattingRoomById(roomId);
List<User> chattingRoomUsers = userQuery.getUsersByRoom(chattingRoom);
chattingRoomUserValidator.validateUserInChattingRoom(requestedUserId, chattingRoomUsers);

List<ChattingMessage> chattingMessages = chattingMessageQuery.getChattingMessagesLessThanMessageId(
chattingRoom, firstMessageId, pageSize);
chattingRoom, lastMessageId, pageSize);
boolean hasNext = chattingMessages.size() >= pageSize;

List<Chatting> chattingList = chattingMessages.stream()
Expand All @@ -55,7 +55,7 @@ public ChattingListDto searchMessages(Long requestedUserId, Long roomId, Long fi
}

@Transactional
public void exitChattingRoom(Long requestUserId, Long roomId, Long firstMessageId) {
public void exitChattingRoom(Long requestUserId, Long roomId, Long chattingRoomLastMessageId) {
ChattingRoom chattingRoom = chattingRoomQuery.getChattingRoomById(roomId);
List<User> chattingRoomUsers = userQuery.getUsersByRoom(chattingRoom);
chattingRoomUserValidator.validateUserInChattingRoom(requestUserId, chattingRoomUsers);
Expand All @@ -64,7 +64,7 @@ public void exitChattingRoom(Long requestUserId, Long roomId, Long firstMessageI
chattingRoom, chattingRoomUsers);
chattingMigrationProcessor.migrateChattingMessagesToHistoryInChattingRoom(chattingRoom,
chattingRoomHistory,
firstMessageId);
chattingRoomLastMessageId);
chattingMigrationProcessor.deleteChattingRoom(chattingRoom, chattingRoomUsers);

Set<NotificationInfo> notificationInfos = chattingRoomUsers.stream()
Expand Down

0 comments on commit c4887c4

Please sign in to comment.