From 07b9bd1a269a7c55af56727eed73d5f2c9549166 Mon Sep 17 00:00:00 2001 From: imjanghyeok Date: Sun, 19 May 2024 11:18:24 +0900 Subject: [PATCH 1/6] =?UTF-8?q?Fix:=20ChatAop=20=EC=97=90=EC=84=9C=20JoinP?= =?UTF-8?q?oint=EB=A1=9C=20=EA=B0=80=EC=A0=B8=EC=98=A8=20=ED=8C=8C?= =?UTF-8?q?=EB=9D=BC=EB=AF=B8=ED=84=B0=20=ED=8C=8C=EC=8B=B1=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/capstone/facefriend/chat/aop/ChatAop.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/capstone/facefriend/chat/aop/ChatAop.java b/src/main/java/capstone/facefriend/chat/aop/ChatAop.java index 9375a0fc0a..5195d272c4 100644 --- a/src/main/java/capstone/facefriend/chat/aop/ChatAop.java +++ b/src/main/java/capstone/facefriend/chat/aop/ChatAop.java @@ -31,6 +31,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.Method; +import java.util.Arrays; import static capstone.facefriend.chat.exception.ChatExceptionType.NOT_FOUND_CHAT_ROOM_MEMBER; import static capstone.facefriend.member.exception.member.MemberExceptionType.NOT_FOUND; @@ -77,10 +78,10 @@ public void afterSendHeart(JoinPoint joinPoint) throws IOException { Long receiveId = -1L; for (int i = 0; i < method.getParameters().length; i++) { String paramName = method.getParameters()[i].getName(); - if (paramName.equals("senderId")) { + if (paramName.equals("arg0")) { senderId = (Long) params[i]; } - if (paramName.equals("receiveId")) { + if (paramName.equals("arg1")) { receiveId = (Long) params[i]; } } @@ -130,7 +131,7 @@ public void beforeSaveChatMessage(JoinPoint joinPoint) throws IOException { ChatMessage chatMessage = null; for (int i = 0; i < method.getParameters().length; i++) { String paramName = method.getParameters()[i].getName(); - if (paramName.equals("chatMessage")) { + if (paramName.equals("arg0")) { chatMessage = (ChatMessage) params[i]; } } @@ -209,10 +210,10 @@ public void beforeLeftRoom(JoinPoint joinPoint) { Long memberId = null; for (int i = 0; i < method.getParameters().length; i++) { String paramName = method.getParameters()[i].getName(); - if (paramName.equals("roomId")) { + if (paramName.equals("arg0")) { roomId = (Long) params[i]; } - if (paramName.equals("memberId")) { + if (paramName.equals("arg1")) { memberId = (Long) params[i]; } } From c1f9b1b4ae67d7d3c218c8ecfe64e1d6552378c1 Mon Sep 17 00:00:00 2001 From: imjanghyeok Date: Sun, 19 May 2024 11:34:37 +0900 Subject: [PATCH 2/6] =?UTF-8?q?Refactor:=20level=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=EB=8C=80=EB=B0=A9=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=9D=84=EC=9A=B0=EA=B8=B0=20=EC=9C=84=ED=95=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20refactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/ChatRoomService.java | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java b/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java index a01d43358f..d752f6f8f0 100644 --- a/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java +++ b/src/main/java/capstone/facefriend/chat/service/ChatRoomService.java @@ -5,7 +5,6 @@ import capstone.facefriend.chat.domain.ChatRoomInfo; import capstone.facefriend.chat.domain.ChatRoomMember; import capstone.facefriend.chat.exception.ChatException; -import capstone.facefriend.chat.exception.ChatExceptionType; import capstone.facefriend.chat.repository.ChatMessageRepository; import capstone.facefriend.chat.repository.ChatRoomInfoRedisRepository; import capstone.facefriend.chat.repository.ChatRoomMemberRepository; @@ -27,7 +26,8 @@ import java.util.List; import java.util.Map; -import static capstone.facefriend.chat.exception.ChatExceptionType.*; +import static capstone.facefriend.chat.exception.ChatExceptionType.NOT_FOUND_CHAT_ROOM; +import static capstone.facefriend.chat.exception.ChatExceptionType.NOT_FOUND_CHAT_ROOM_MEMBER; @Service @Slf4j @@ -105,22 +105,50 @@ public Map getChatRoomList(Long memberId) { ChatRoom.Status status = chatRoomMember.getChatRoom().getStatus(); if (status == ChatRoom.Status.set) { + String memberFaceInfo = ""; + String senderFaceInfo = ""; Member sender = identifySender(chatRoomMember, memberId); Boolean isSender = isSender(chatRoomMember, memberId); - ChatRoomHeartResponse chatRoomHeartResponse = ChatRoomHeartResponse.of(member, sender, chatRoomMember.getChatRoom(), isSender); + if(isSender == true) { + memberFaceInfo = chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url(); + senderFaceInfo = chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url(); + } else { + memberFaceInfo = chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url(); + senderFaceInfo = chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url(); + } + ChatRoomHeartResponse chatRoomHeartResponse = ChatRoomHeartResponse.of(member, sender, chatRoomMember.getChatRoom(), senderFaceInfo, memberFaceInfo,isSender); chatRoomsHeart.add(chatRoomHeartResponse); } else if (status == ChatRoom.Status.progress) { + String memberFaceInfo = ""; + String senderFaceInfo = ""; Member sender = identifySender(chatRoomMember, memberId); ChatMessage chatMessage = chatMessageRepository.findFirstByChatRoomIdOrderBySendTimeDesc(chatRoomMember.getChatRoom().getId()); - ChatRoomMessageResponse chatRoomResponse = ChatRoomMessageResponse.of(member, sender, chatRoomMember.getChatRoom(), chatMessage); + Boolean isSender = isSender(chatRoomMember, memberId); + if(isSender == true) { + memberFaceInfo = chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url(); + senderFaceInfo = chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url(); + } else { + memberFaceInfo = chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url(); + senderFaceInfo = chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url(); + } + ChatRoomMessageResponse chatRoomResponse = ChatRoomMessageResponse.of(member, sender, chatRoomMember.getChatRoom(), senderFaceInfo, memberFaceInfo, chatMessage); chatRoomsMessage.add(chatRoomResponse); } else if (status == ChatRoom.Status.open) { + String memberFaceInfo = ""; + String senderFaceInfo = ""; Member sender = identifySender(chatRoomMember, memberId); - ChatRoomOpenResponse chatRoomOpenResponse = ChatRoomOpenResponse.of(member, sender, chatRoomMember.getChatRoom(), OPEN_MESSAGE); + Boolean isSender = isSender(chatRoomMember, memberId); + if(isSender == true) { + memberFaceInfo = chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url(); + senderFaceInfo = chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url(); + } else { + memberFaceInfo = chatRoomMember.getReceiverFaceInfoByLevel().getGeneratedByLevelS3url(); + senderFaceInfo = chatRoomMember.getSenderFaceInfoByLevel().getGeneratedByLevelS3url(); + } + ChatRoomOpenResponse chatRoomOpenResponse = ChatRoomOpenResponse.of(member, sender, chatRoomMember.getChatRoom(), senderFaceInfo, memberFaceInfo, OPEN_MESSAGE); chatRoomsOpen.add(chatRoomOpenResponse); - } else if (status == ChatRoom.Status.close) { Member leftMember = identifyLeftMember(memberId, chatRoomMember); if (member != leftMember) { From baf64a096607549f0c43e9fd4c0a4f2a7db0ade7 Mon Sep 17 00:00:00 2001 From: imjanghyeok Date: Sun, 19 May 2024 11:35:06 +0900 Subject: [PATCH 3/6] =?UTF-8?q?Refactor:=20level=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=EB=8C=80=EB=B0=A9=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EB=9D=84=EC=9A=B0=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20open=20=EC=83=81=ED=83=9C=EC=9D=98=20chatroom=20dto?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/dto/chatroom/ChatRoomOpenResponse.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java index a968a98ac5..3be802340a 100644 --- a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomOpenResponse.java @@ -15,18 +15,18 @@ public record ChatRoomOpenResponse ( ChatRoom chatRoom, String message ) { - public static ChatRoomOpenResponse of(Member member, Member sender, ChatRoom chatRoom, String message) { + public static ChatRoomOpenResponse of(Member member, Member sender, ChatRoom chatRoom, String senderFaceInfo, String memberFaceInfo, String openMessage) { return new ChatRoomOpenResponse( member.getId(), member.getBasicInfo().getNickname(), - member.getFaceInfo().getGeneratedS3url(), + memberFaceInfo, member.getFaceInfo().getOriginS3url(), sender.getId(), sender.getBasicInfo().getNickname(), - sender.getFaceInfo().getGeneratedS3url(), + senderFaceInfo, sender.getFaceInfo().getOriginS3url(), chatRoom, - message + openMessage ); } } \ No newline at end of file From 65b052588c55da9f725ecfb68e72bf1111aa57f8 Mon Sep 17 00:00:00 2001 From: imjanghyeok Date: Sun, 19 May 2024 11:35:14 +0900 Subject: [PATCH 4/6] =?UTF-8?q?Refactor:=20level=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=EB=8C=80=EB=B0=A9=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EB=9D=84=EC=9A=B0=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20progress=20=EC=83=81=ED=83=9C=EC=9D=98=20chatroom?= =?UTF-8?q?=20dto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/dto/chatroom/ChatRoomMessageResponse.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java index cd4287dd5d..99d95ea279 100644 --- a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomMessageResponse.java @@ -17,15 +17,15 @@ public record ChatRoomMessageResponse( String content ){ - public static ChatRoomMessageResponse of(Member member, Member sender, ChatRoom chatRoom, ChatMessage message) { + public static ChatRoomMessageResponse of(Member member, Member sender, ChatRoom chatRoom, String senderFaceInfo, String memberFaceInfo, ChatMessage message) { return new ChatRoomMessageResponse( member.getId(), member.getBasicInfo().getNickname(), - member.getFaceInfo().getGeneratedS3url(), + memberFaceInfo, member.getFaceInfo().getOriginS3url(), sender.getId(), sender.getBasicInfo().getNickname(), - sender.getFaceInfo().getGeneratedS3url(), + senderFaceInfo, sender.getFaceInfo().getOriginS3url(), chatRoom, message.getContent() From 5ca9b235213e323ed11642c43522ba5be7611750 Mon Sep 17 00:00:00 2001 From: imjanghyeok Date: Sun, 19 May 2024 11:35:20 +0900 Subject: [PATCH 5/6] =?UTF-8?q?Refactor:=20level=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EB=8A=94=20=EC=83=81=EB=8C=80=EB=B0=A9=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EB=9D=84=EC=9A=B0=EA=B8=B0=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20set=20=EC=83=81=ED=83=9C=EC=9D=98=20chatroom=20dto?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/service/dto/chatroom/ChatRoomHeartResponse.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java index 341fc1f584..48a59d1b9c 100644 --- a/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java +++ b/src/main/java/capstone/facefriend/chat/service/dto/chatroom/ChatRoomHeartResponse.java @@ -16,15 +16,15 @@ public record ChatRoomHeartResponse ( Boolean isSender ) { - public static ChatRoomHeartResponse of(Member member, Member sender, ChatRoom chatRoom, Boolean isSender) { + public static ChatRoomHeartResponse of(Member member, Member sender, ChatRoom chatRoom, String senderFaceInfo, String memberFaceInfo, Boolean isSender) { return new ChatRoomHeartResponse( member.getId(), member.getBasicInfo().getNickname(), - member.getFaceInfo().getGeneratedS3url(), + memberFaceInfo, member.getFaceInfo().getOriginS3url(), sender.getId(), sender.getBasicInfo().getNickname(), - sender.getFaceInfo().getGeneratedS3url(), + senderFaceInfo, sender.getFaceInfo().getOriginS3url(), chatRoom, isSender From 9bda406a6f4e7d577328b44622210e8cd357ff25 Mon Sep 17 00:00:00 2001 From: imjanghyeok Date: Sun, 19 May 2024 12:35:18 +0900 Subject: [PATCH 6/6] =?UTF-8?q?Refactor:=20=EC=9B=90=EB=9E=98=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/capstone/facefriend/chat/aop/ChatAop.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/capstone/facefriend/chat/aop/ChatAop.java b/src/main/java/capstone/facefriend/chat/aop/ChatAop.java index 5195d272c4..f1dc47569a 100644 --- a/src/main/java/capstone/facefriend/chat/aop/ChatAop.java +++ b/src/main/java/capstone/facefriend/chat/aop/ChatAop.java @@ -31,7 +31,6 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.lang.reflect.Method; -import java.util.Arrays; import static capstone.facefriend.chat.exception.ChatExceptionType.NOT_FOUND_CHAT_ROOM_MEMBER; import static capstone.facefriend.member.exception.member.MemberExceptionType.NOT_FOUND; @@ -78,10 +77,10 @@ public void afterSendHeart(JoinPoint joinPoint) throws IOException { Long receiveId = -1L; for (int i = 0; i < method.getParameters().length; i++) { String paramName = method.getParameters()[i].getName(); - if (paramName.equals("arg0")) { + if (paramName.equals("senderId")) { senderId = (Long) params[i]; } - if (paramName.equals("arg1")) { + if (paramName.equals("receiveId")) { receiveId = (Long) params[i]; } } @@ -131,7 +130,7 @@ public void beforeSaveChatMessage(JoinPoint joinPoint) throws IOException { ChatMessage chatMessage = null; for (int i = 0; i < method.getParameters().length; i++) { String paramName = method.getParameters()[i].getName(); - if (paramName.equals("arg0")) { + if (paramName.equals("chatMessage")) { chatMessage = (ChatMessage) params[i]; } } @@ -210,10 +209,10 @@ public void beforeLeftRoom(JoinPoint joinPoint) { Long memberId = null; for (int i = 0; i < method.getParameters().length; i++) { String paramName = method.getParameters()[i].getName(); - if (paramName.equals("arg0")) { + if (paramName.equals("roomId")) { roomId = (Long) params[i]; } - if (paramName.equals("arg1")) { + if (paramName.equals("memberId")) { memberId = (Long) params[i]; } } @@ -272,4 +271,4 @@ private ChatRoomMember findChatRoomMemberByRoomId(Long roomId) { return chatRoomMemberRepository.findByChatRoomId(roomId) .orElseThrow(() -> new ChatException(NOT_FOUND_CHAT_ROOM_MEMBER)); // 영속 } -} +} \ No newline at end of file