From 70fb8f0b5718f70407076095d33091d98a83f5b4 Mon Sep 17 00:00:00 2001
From: sungjiwoon <nebulaisme@naver.com>
Date: Sat, 27 Jan 2024 14:42:37 +0900
Subject: [PATCH] =?UTF-8?q?fix=20:=20isNego=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../chatroom/dto/ChatRoomListGetResponse.java | 27 +++++++++++++++++--
 .../chat/message/service/ChatService.java     |  3 ++-
 2 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java b/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java
index 8be29f1..582c9c4 100644
--- a/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java
+++ b/src/main/java/com/catchroom/chat/chatroom/dto/ChatRoomListGetResponse.java
@@ -43,6 +43,8 @@ public class ChatRoomListGetResponse implements Serializable {
 
     private ChatMessageDto lastChatmessageDto;
 
+    private Boolean isNego;
+
 
     public void updateChatMessageDto(ChatMessageDto chatMessageDto) {
         this.lastChatmessageDto = chatMessageDto;
@@ -53,10 +55,31 @@ public void changePartnerInfo() {
         this.myNickName = partnerNickName;
         this.partnerNickName = tmp;
 
-        if (loginUserIdentity.equals(UserIdentity.SELLER)) {
+        if (this.loginUserIdentity.equals(UserIdentity.SELLER)) {
             this.loginUserIdentity = UserIdentity.BUYER;
-        } else if (loginUserIdentity.equals(UserIdentity.BUYER)) {
+        } else if (this.loginUserIdentity.equals(UserIdentity.BUYER)) {
             this.loginUserIdentity = UserIdentity.SELLER;
         }
     }
+
+    @Override
+    public String toString() {
+        return "ChatRoomListGetResponse{" +
+                "chatRoomNumber='" + chatRoomNumber + '\'' +
+                ", buyerId=" + buyerId +
+                ", sellerId=" + sellerId +
+                ", productId=" + productId +
+                ", accommodationName='" + accommodationName + '\'' +
+                ", sellPrice=" + sellPrice +
+                ", loginUserIdentity=" + loginUserIdentity +
+                ", accommodationUrl='" + accommodationUrl + '\'' +
+                ", myNickName='" + myNickName + '\'' +
+                ", partnerNickName='" + partnerNickName + '\'' +
+                ", dealState=" + dealState +
+                ", buyerState=" + buyerState +
+                ", sellerState=" + sellerState +
+                ", lastChatmessageDto=" + lastChatmessageDto +
+                ", isNego=" + isNego +
+                '}';
+    }
 }
diff --git a/src/main/java/com/catchroom/chat/message/service/ChatService.java b/src/main/java/com/catchroom/chat/message/service/ChatService.java
index 2e49e19..f04a795 100644
--- a/src/main/java/com/catchroom/chat/message/service/ChatService.java
+++ b/src/main/java/com/catchroom/chat/message/service/ChatService.java
@@ -124,11 +124,12 @@ private void setNewChatRoomInfo(ChatMessageDto chatMessage, ChatRoomListGetRespo
             newChatRoomListResponse.changePartnerInfo(); //닉네임 체인지
             chatRoomRedisRepository.setChatRoom(newChatRoomListResponse.getBuyerId(), chatMessage.getRoomId(), newChatRoomListResponse);
 
-        } else {
+        } else if (newChatRoomListResponse.getLoginUserIdentity().equals(UserIdentity.BUYER)){
             if (!chatMessage.getType().equals(MessageType.DELETE)) {
                 chatRoomRedisRepository.setChatRoom(newChatRoomListResponse.getBuyerId(),
                         chatMessage.getRoomId(), newChatRoomListResponse);
             }
+
             newChatRoomListResponse.changePartnerInfo(); //닉네임 체인지
             chatRoomRedisRepository.setChatRoom(newChatRoomListResponse.getSellerId(), chatMessage.getRoomId(), newChatRoomListResponse);
         }