From 3745f3f9aefc6dddfe78074cd473975786e26378 Mon Sep 17 00:00:00 2001 From: geneaky Date: Tue, 21 May 2024 23:25:54 +0900 Subject: [PATCH] revise: fetch user chatroom using banned exploded condition --- .../repository/query/ChatRoomQueryRepositoryImpl.java | 5 ++++- .../query/dto/response/ChatRoomResponse.java | 2 -- .../query/dto/response/UserChatRoomResponse.java | 11 +++++++++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/ChatRoomQueryRepositoryImpl.java b/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/ChatRoomQueryRepositoryImpl.java index 012d6690..11bda109 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/ChatRoomQueryRepositoryImpl.java +++ b/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/ChatRoomQueryRepositoryImpl.java @@ -87,11 +87,14 @@ public Slice findUserChatRoomsWithLastChat(Pageable pageab user.defaultProfileImageType, chat.id, chat.message, - chat.createdAt + chat.createdAt, + chatRoomBlockedUser.id.isNotNull(), + chatRoom.isDeleted )) .from(chatRoom) .join(participant).on(participant.chatRoom.eq(chatRoom).and(participant.user.id.eq(userId))) //사용자 채팅방 .leftJoin(subParticipant).on(subParticipant.chatRoom.eq(chatRoom)) // 채팅방 인원수 + .leftJoin(chatRoomBlockedUser).on(chatRoomBlockedUser.chatRoom.id.eq(chatRoom.id).and(chatRoomBlockedUser.user.id.eq(userId))) .leftJoin(chat).on(chat.id.eq( // 마지막 채팅, 채팅 내 JPAExpressions.select(subChat.id.max()) .from(subChat) diff --git a/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/ChatRoomResponse.java b/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/ChatRoomResponse.java index fed51f4d..7c7870bb 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/ChatRoomResponse.java +++ b/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/ChatRoomResponse.java @@ -5,10 +5,8 @@ import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.ToString; @Getter -@ToString @EqualsAndHashCode public class ChatRoomResponse { diff --git a/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/UserChatRoomResponse.java b/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/UserChatRoomResponse.java index 4c6844d0..804a0b13 100644 --- a/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/UserChatRoomResponse.java +++ b/src/main/java/toy/bookchat/bookchat/domain/chatroom/repository/query/dto/response/UserChatRoomResponse.java @@ -29,11 +29,13 @@ public class UserChatRoomResponse { private Long lastChatId; private String lastChatContent; private LocalDateTime lastChatDispatchTime; + private Boolean isBanned; + private Boolean isExploded; @Builder public UserChatRoomResponse(Long roomId, String roomName, String roomSid, Long roomMemberCount, Integer defaultRoomImageType, String roomImageUri, String bookTitle, String bookCoverImageUrl, List bookAuthors, Long senderId, String senderNickname, String senderProfileImageUrl, Integer senderDefaultProfileImageType, Long lastChatId, String lastChatContent, - LocalDateTime lastChatDispatchTime) { + LocalDateTime lastChatDispatchTime, Boolean isBanned, Boolean isExploded) { this.roomId = roomId; this.roomName = roomName; this.roomSid = roomSid; @@ -50,10 +52,13 @@ public UserChatRoomResponse(Long roomId, String roomName, String roomSid, Long r this.lastChatId = lastChatId; this.lastChatContent = lastChatContent; this.lastChatDispatchTime = lastChatDispatchTime; + this.isBanned = isBanned; + this.isExploded = isExploded; } public UserChatRoomResponse(Long roomId, String roomName, String roomSid, Long roomMemberCount, Integer defaultRoomImageType, String roomImageUri, Long senderId, String senderNickname, - String senderProfileImageUrl, Integer senderDefaultProfileImageType, Long lastChatId, String lastChatContent, LocalDateTime lastChatDispatchTime) { + String senderProfileImageUrl, Integer senderDefaultProfileImageType, Long lastChatId, String lastChatContent, LocalDateTime lastChatDispatchTime, Boolean isBanned, + Boolean isExploded) { this.roomId = roomId; this.roomName = roomName; this.roomSid = roomSid; @@ -67,6 +72,8 @@ public UserChatRoomResponse(Long roomId, String roomName, String roomSid, Long r this.lastChatId = lastChatId; this.lastChatContent = lastChatContent; this.lastChatDispatchTime = lastChatDispatchTime; + this.isBanned = isBanned; + this.isExploded = isExploded; } public void setBookInfo(Book book) {