Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[COZY-400] feat: 쪽지방 목록 정렬 및 새로운 쪽지 유무 반환 추가, 새로운 쪽지 온 쪽지방 갯수 조회 API, 회원탈퇴 쪽지 null 처리 #191

Merged
merged 5 commits into from
Nov 28, 2024

Conversation

veronees
Copy link
Member

@veronees veronees commented Nov 26, 2024

⚒️develop의 최신 커밋을 pull 받았나요?

#️⃣ 작업 내용

어떤 기능을 구현했나요?
기존 기능에서 어떤 점이 달라졌나요?
자세한 로직이 필요하다면 함께 적어주세요!
코드에 대한 설명이라면, 코맨트를 통해서 어떤 부분이 어떤 코드인지 설명해주세요!

  • 쪽지방 목록 정렬
  • 새로운 쪽지 유무 반환 추가
  • 새로운 쪽지가 온 쪽지방 갯수 조회 API
  • 회원탈퇴 쪽지 null 처리

동작 확인

기능을 실행했을 때 정상 동작하는지 여부를 확인하고 스샷을 올려주세요

마지막 쪽지방 읽은 시간 기준 이후에 쪽지가 온 경우 true를 반환
image

새 쪽지가 눈꽃에서만 왔기 때문에 새로운 쪽지방 갯수 조회 = 1
image

포비 계정으로 베로에게 쪽지 하나를 보낸 경우 - true반환, 최근 쪽지가 오고 간 순서대로 정렬됌
image

새로운 쪽지방 갯수 조회 = 2
image

쪽지방 목록 조회 시 탈퇴한 멤버 (알수없음)으로 처리
image

탈퇴한 멤버와의 쪽지 상세 조회
image

💬 리뷰 요구사항(선택)

리뷰어가 특별히 봐주었으면 하는 부분이 있다면 작성해주세요
고민사항도 적어주세요.

null 처리 최대한 한다고 했는데 오류 생기면 수정할게요

아직 쪽지방 삭제는 null 처리하고 테스트를 못해봤어요

@veronees veronees added the enhancement New feature or request label Nov 26, 2024
@veronees veronees self-assigned this Nov 26, 2024
Copy link

리뷰해드려요~

  1. ChatRepository.java
  • Added existsBySenderAndChatRoomAndCreatedAtAfterOrLastSeenAtIsNull method to check if there is a new chat message.
  • Imported LocalDateTime and Member classes.
  1. ChatQueryService.java
  • Modified getChatList method to return ChatListResponseDTO instead of List<Chat>.
  • Added updateLastSeenAt method to update the last seen at time of the recipient.
  • Modified toChatResponseDTOList method to handle null sender and add self indicator.
  • Imported Objects class.
  1. ChatRoom.java
  • Added memberALastSeenAt and memberBLastSeenAt fields and their corresponding update methods.
  1. ChatRoomController.java
  • Added getCountChatRoomsWithNewChat method to get the count of chat rooms with new chat messages.
  • Imported CountChatRoomsWithNewChatDTO class.
  1. ChatRoomConverter.java
  • Added toCountChatRoomsWithNewChatDTO method to convert the count to CountChatRoomsWithNewChatDTO.
  • Imported CountChatRoomsWithNewChatDTO class.
  1. ChatRoomDetailResponseDTO.java
  • Added hasNewChat field.
  1. CountChatRoomsWithNewChatDTO.java
  • Created a new record class to hold the count of chat rooms with new chat messages.
  1. ChatRoomQueryService.java
  • Modified getChatRoomList method to return ChatRoomDetailResponseDTO instead of List<ChatRoom>.
  • Added countChatRoomsWithNewChat method to get the count of chat rooms with new chat messages.
  • Modified getLatestChatByChatRoom method to handle null sender and recipient.
  • Modified getLastDeleteAtByMember method to handle null sender and recipient.
  • Added existNewChat method to check if there is a new chat message.
  • Imported Objects class.

These changes allow the system to handle new chat messages and update the last seen at time of the recipient. The new endpoint getCountChatRoomsWithNewChat allows the user to get the count of chat rooms with new chat messages. The modified endpoint getChatRoomList returns the list of chat rooms with new chat messages and the last seen at time of the recipient. The modified methods getLatestChatByChatRoom, getLastDeleteAtByMember, and existNewChat handle the null sender and recipient cases. The modified toChatResponseDTOList method handles the null sender case and adds a self indicator.

Copy link
Member Author

@veronees veronees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

코멘트 단 부분 외에는 대부분 null 처리입니다


return memberBlockUtil.filterBlockedMember(chatRoomDetailResponseDTOList, member,
ChatRoomDetailResponseDTO::memberId);
public CountChatRoomsWithNewChatDTO countChatRoomsWithNewChat(Member member) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로운 쪽지 온 쪽지방 갯수 계산하는 메서드입니다

if (chat == null) {
return false;
}
LocalDateTime lastDeleteAt = getLastDeleteAtByMember(chatRoom, member);
return lastDeleteAt == null || chat.getCreatedAt().isAfter(lastDeleteAt);
})
.sorted((chatRoomA, chatRoomB) -> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쪽지방 목록 대화 내용 최신순으로 정렬했습니다

Comment on lines +71 to +84
if (Objects.isNull(chatRoom.getMemberA()) ||
Objects.isNull(chatRoom.getMemberB())) {
return toChatRoomDetailResponseDTO(chatRoom, member, chat, false);
}

Member recipient = chatRoom.getMemberA().getId().equals(member.getId()) ?
chatRoom.getMemberB() : chatRoom.getMemberA();

LocalDateTime lastSeenAt = chatRoom.getMemberA().getId().equals(member.getId()) ?
chatRoom.getMemberALastSeenAt() : chatRoom.getMemberBLastSeenAt();

boolean hasNewChat = existNewChat(recipient, chatRoom, lastSeenAt);

return toChatRoomDetailResponseDTO(chatRoom, member, chat, hasNewChat);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쪽지방 목록 조회 시 새로운 쪽지 유무 추가하는 부분입니다

Copy link
Member

@eple0329 eple0329 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


@Builder
public record CountChatRoomsWithNewChatDTO(
Integer hasNewChatCount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 newChatCount는 어떤가요? has가 붙으면 boolean을 생각하게 될 것 같습니당

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newChatCount보다 좀 더 길지만 확실한 이름으로 변경했슴다

Comment on lines 60 to 61
if (Objects.nonNull(memberALastDeleteAt) && Objects.nonNull(memberBLastDeleteAt)
&& canHardDelete(chatRoom, memberALastDeleteAt, memberBLastDeleteAt)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리팩토링할 때 이런 부분은 따로 함수로 빼서 true, false 반환되는 함수를 만든다면 더 읽기 편할 것 같습니당

Copy link
Contributor

@jpark0506 jpark0506 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM~ 이상 없어보이네요 만약 읽으면 그 상태를 바꿔주는 API는 따로 있는건가요?

Copy link

리뷰해드려요~

  • {name} ChatRepository.java

  • Added a method to check if there is a new chat message for the given member and chat room.

  • Added a new import for Member and LocalDateTime.

  • {name} ChatQueryService.java

  • Added a method to update the last seen at timestamp for the given member and chat room.

  • Added a new import for LocalDateTime.

  • Modified the getChatList method to use the new method to update the last seen at timestamp.

  • Modified the toChatContentResponseDTO method to handle the case when the sender is null.

  • Removed the checkBlockedMember method and its usage in the getChatList method.

  • {name} ChatRoom.java

  • Added two new fields and their corresponding getter and setter methods to store the last seen at timestamps for member A and member B.

  • {name} ChatRoomController.java

  • Added a new method to get the count of chat rooms with new chat messages for the given member.

  • Added a new import for CountChatRoomsWithNewChatDTO.

  • {name} ChatRoomConverter.java

  • Added a new method to convert a CountChatRoomsWithNewChatDTO object to a CountChatRoomsWithNewChatDTO object.

  • Added a new import for CountChatRoomsWithNewChatDTO.

  • {name} ChatRoomDetailResponseDTO.java

  • Added a new field and its corresponding getter and setter method to store the hasNewChat flag.

  • {name} CountChatRoomsWithNewChatDTO.java

  • Added a new record class to represent the count of chat rooms with new chat messages.

  • {name} ChatRoomQueryService.java

  • Added a new method to count the chat rooms with new chat messages for the given member.

  • Modified the getChatRoomList method to use the new method to count the chat rooms with new chat messages.

  • Modified the getChatRoom method to use the new method to count the chat rooms with new chat messages.

  • Added a new import for CountChatRoomsWithNewChatDTO.

The changes made in the code are to add new features to the chat room and chat message functionalities. The new features include checking if there is a new chat message for a given member and chat room, updating the last seen at timestamp for a given member and chat room, and counting the chat rooms with new chat messages for a given member. The changes also include adding new classes and methods to support these new features.

@veronees
Copy link
Member Author

veronees commented Nov 28, 2024

해당 쪽지방 마지막 조회 시간 추가해서 마지막 조회 시간으로 새 쪽지 있는지 확인만해용
따로 상태를 바꿔주거나 하진 않습니다

@veronees veronees merged commit 5c81f50 into develop Nov 28, 2024
1 check passed
@veronees veronees deleted the feature/COZY-400 branch November 28, 2024 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants