Skip to content

Commit

Permalink
[FIX] 채팅 내역만큼 채팅방 목록이 반환되는 버그 수정 (#109)
Browse files Browse the repository at this point in the history
resolve #108
  • Loading branch information
Profile-exe authored Jul 25, 2024
1 parent 4f75192 commit dec5cee
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

import com.querydsl.core.types.dsl.BooleanExpression;
import com.querydsl.core.types.dsl.CaseBuilder;
import com.querydsl.jpa.JPAExpressions;
import com.querydsl.jpa.impl.JPAQueryFactory;
import econo.buddybridge.chat.chatmessage.entity.QChatMessage;
import econo.buddybridge.matching.dto.MatchingCustomPage;
import econo.buddybridge.matching.dto.MatchingResDto;
import econo.buddybridge.matching.dto.QMatchingResDto;
Expand All @@ -28,6 +30,8 @@ public class MatchingRepositoryCustomImpl implements MatchingRepositoryCustom {
public MatchingCustomPage findMatchings(Long memberId, Integer size, LocalDateTime cursor, MatchingStatus matchingStatus, Pageable page) {
int pageSize = page.getPageSize();

QChatMessage subChatMessage = new QChatMessage("subChatMessage");

List<MatchingResDto> matchingResDtos = queryFactory
.select(new QMatchingResDto(
matching.id,
Expand All @@ -44,7 +48,11 @@ public MatchingCustomPage findMatchings(Long memberId, Integer size, LocalDateTi
)
))
.from(matching)
.leftJoin(chatMessage).on(chatMessage.matching.id.eq(matching.id))
.leftJoin(chatMessage).on(chatMessage.matching.eq(matching)
.and(chatMessage.id.eq(JPAExpressions
.select(subChatMessage.id.max())
.from(subChatMessage)
.where(subChatMessage.matching.eq(matching)))))
.leftJoin(member).on(
member.id.eq(
new CaseBuilder()
Expand Down

0 comments on commit dec5cee

Please sign in to comment.