Skip to content

Conversation

@Soundbar91
Copy link
Collaborator

🔍 개요

  • chat 도메인 리팩토링을 진행합니다.

🚀 주요 변경 내용

chat_room 테이블 컬럼 추가

  • chat_room 테이블에 컬럼을 추가했습니다.
    • last_message
    • last_message_sent_at
  • 해당 컬럼에는 마지막으로 보내는 메시지와 시각이 저장됩니다.
  • 채팅방 리스트를 조회할 때, 해당 컬럼에서 데이터를 가져가도록 로직을 수정했습니다.

채팅방 리스트 정렬 조건 수정

  • 채팅방의 정렬 조건을 생성일이 아닌, 마지막 메시지 전송 시간으로 수정했습니다.

ChatRoom의 OneToMany 삭제

  • ChatRoom 클래스에서 OneToMany로 걸려있는 ChatMessage를 삭제했습니다.

💬 참고 사항


✅ Checklist (완료 조건)

  • 코드 스타일 가이드 준수
  • 테스트 코드 포함됨
  • Reviewers / Assignees / Labels 지정 완료
  • 보안 및 민감 정보 검증 (API 키, 환경 변수, 개인정보 등)

soundbar91 added 22 commits December 26, 2025 11:20
@Soundbar91 Soundbar91 requested a review from dh2906 December 26, 2025 05:19
@Soundbar91 Soundbar91 self-assigned this Dec 26, 2025
@Soundbar91 Soundbar91 added the 리팩토링 리팩터링을 위한 이슈입니다. label Dec 26, 2025
Copy link
Contributor

@dh2906 dh2906 left a comment

Choose a reason for hiding this comment

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

고생하셨습니다!

LEFT JOIN FETCH cr.chatMessages
WHERE cr.sender.id = :userId OR cr.receiver.id = :userId
ORDER BY cr.updatedAt DESC
ORDER BY cr.lastMessageSentAt DESC NULLS LAST
Copy link
Contributor

Choose a reason for hiding this comment

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

lastMessageSentAtNULL인 채팅방이 여럿인 경우 정렬 기준이 어떻게 되어 나오나요??

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DB가 읽은 순서대로 나오는 거 같은데, 추가 정렬 기준으로 id를 넣으면 좋을 거 같네용

@Soundbar91 Soundbar91 merged commit 9b3f612 into main Dec 27, 2025
1 check passed
@Soundbar91 Soundbar91 deleted the refactor/CAM-129-chat branch December 27, 2025 10:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

리팩토링 리팩터링을 위한 이슈입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants