Skip to content

Commit

Permalink
Merge pull request #82 from kookmin-sw/refactor/roomlist
Browse files Browse the repository at this point in the history
[Refactor] roomlist에서 level에 맞는 상대방 이미지
  • Loading branch information
imjanghyeok authored May 19, 2024
2 parents 8019c47 + 9bda406 commit 16f86ea
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/java/capstone/facefriend/chat/aop/ChatAop.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,4 @@ private ChatRoomMember findChatRoomMemberByRoomId(Long roomId) {
return chatRoomMemberRepository.findByChatRoomId(roomId)
.orElseThrow(() -> new ChatException(NOT_FOUND_CHAT_ROOM_MEMBER)); // 영속
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -105,22 +105,50 @@ public Map<String, Object> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
}

0 comments on commit 16f86ea

Please sign in to comment.