Skip to content

Commit

Permalink
Merge pull request #281 from Geek-sasaeng/tomas
Browse files Browse the repository at this point in the history
Tomas/#237 fix: 채팅방 목록 조회API-리스트 stream.sort조건 추가
  • Loading branch information
xhaktmchl authored Jan 15, 2023
2 parents c8a708d + 2802d9a commit 296960f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,9 @@ public int hashCode() {
result = 31 * result + (getBaseEntityMongo() != null ? getBaseEntityMongo().hashCode() : 0);
return result;
}


public LocalDateTime getLastChatAt(){
return this.partyChatRoom.getLastChatAt();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -231,7 +232,8 @@ public GetPartyChatRoomsRes findPartyChatRooms(int memberId, int cursor) {
PageRequest page = PageRequest.of(cursor, 10, Sort.by(Sort.Direction.DESC, PAGING_STANDARD));
Slice<PartyChatRoomMember> members = partyChatRoomMemberRepository.findPartyChatRoomMemberByMemberId(memberId, page);
List<GetPartyChatRoomRes> result = members.stream()
//.filter(member -> member.getPartyChatRoom().getBaseEntityMongo().getStatus() == BaseStatus.ACTIVE)
//.filter(member -> member.getPartyChatRoom().getBaseEntityMongo().getStatus() == BaseStatus.ACTIVE) // 필터링에서 에러 남
.sorted(Comparator.comparing(PartyChatRoomMember::getLastChatAt).reversed()) //TODO: 최신 메시지 순으로 정렬했지만 메소드 정의 위치가 맞는지 테스트 필요
.map(member -> GetPartyChatRoomRes.of(member.getPartyChatRoom()))
.collect(Collectors.toList());

Expand Down

0 comments on commit 296960f

Please sign in to comment.