-
Notifications
You must be signed in to change notification settings - Fork 2
feat(be): userChat 도메인 임시 기능 구현 #41
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 AI 리뷰 - src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/UserChatSseEvents.kt
🟢 좋은점
- Kotlin 최적화: null safety가 잘 적용되어 있습니다.
emitters[roomId]?.toList()?.forEach처럼 옵셔널 체이닝을 사용해 null 포인터 예외를 방지하고,computeIfAbsent로 맵 초기화를 안전하게 처리합니다. 또한,ConcurrentHashMap과MutableList를 활용한 동시성 처리가 적절하며, Kotlin의 idiomatic한 스타일(예: 람다 기반 콜백onCompletion,onTimeout)을 따릅니다. - ktlint 규칙: 코드 포맷팅이 일관적이며, 네이밍 컨벤션(예:
subscribe,publishNew메서드명, camelCase 변수명)이 ktlint 표준을 준수합니다. 불필요한 공백이나 들여쓰기 오류가 없어 보입니다. - 전반적 구조: SSE Emitter의 생명주기 관리(
onCompletion,onTimeout,complete())가 적절히 구현되어 메모리 누수를 방지합니다.toList()를 사용해 컬렉션을 복사한 후 반복하는 방식으로 동시 수정 문제를 피한 점이 좋습니다.
🟡 개선사항
- Kotlin 최적화:
publishNew메서드에서toList()?.forEach는 좋지만, 더 Kotlin다운 방식으로emitters[roomId]?.toList()?.forEach { ... }를 확장 함수나let/also로 감싸서 가독성을 높일 수 있습니다. 예:emitters[roomId]?.toList()?.let { list -> list.forEach { ... } }. 또한,lastMessageId를 데이터로 보내는 부분이 명확하지만, 이벤트 데이터를 더 구조화된 객체(예: data class)로 wrapping하면 확장성이 좋아집니다. - ktlint 규칙: 주석이 영어와 한국어 혼용되어 있지만, 일관성을 위해 영어로 통일하거나 Javadoc 스타일로 개선하면 좋습니다. (예:
// Websocket,Stomp 사용 전 임시로 만들었음→// Temporary implementation for SSE before switching to WebSocket/STOMP. To be removed after testing.) - **
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 AI 리뷰 - src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatmessage/entity/ChatMessage.kt
🟢 좋은점:
- Kotlin data class를 적절히 사용하며, null safety를 준수하고 있습니다.
content필드가nullable = false로 명시되어 non-null 타입(String)으로 안전하게 처리되고 있으며,createdAt의 기본값(Instant.now())도 Kotlin의 기본 매개변수 기능을 활용한 최적화 예시입니다.
🟡 개선사항:
@Column어노테이션의 속성 순서(nullable을 먼저 배치)가 변경되었으나, ktlint 규칙(예: 어노테이션 속성의 알파벳 순서나 JPA 컨벤션 준수)을 고려하면columnDefinition을 먼저 두는 것이 더 일관성 있게 보일 수 있습니다. ktlint 설정에 따라 포맷팅을 재검토하세요. (예:columnDefinition = "text", nullable = false순서 추천)
🔴 문제점:
@Column에name속성이 명시되지 않았습니다. JPA에서 필드 이름(content)이 자동으로 컬럼 이름으로 매핑되지만, 명확성을 위해@Column(name = "content", nullable = false, columnDefinition = "text")처럼 추가하는 것이 표준 관례입니다. 이는 데이터베이스 스키마 변경 시 혼란을 방지할 수 있습니다. 반드시 수정하세요.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤖 AI 리뷰 - src/main/kotlin/com/back/koreaTravelGuide/domain/userChat/chatmessage/repository/ChatMessageRepository.kt
🟢 좋은점:
- Kotlin 최적화 측면에서 간결한 메서드 선언으로 null safety나 추가 타입 지정 없이 Spring Data JPA의 쿼리 메서드 컨벤션을 잘 따름 (deleteBy + 필드명). 이는 Kotlin의 간결성을 활용한 좋은 예.
- ktlint 규칙 준수: 네이밍 컨벤션 (camelCase, 의미 있는 이름)이 적절하며, 포맷팅 (들여쓰기, 줄바꿈)이 표준에 맞음.
🟡 개선사항:
- Kotlin 최적화: 메서드 반환 타입을 명시적으로
Unit으로 지정하면 (fun deleteByRoomId(roomId: Long): Unit) 더 명확해질 수 있음. 현재는 암시적 Unit이지만, 대규모 프로젝트에서 가독성을 위해 고려. - ktlint 규칙: 변경사항의 diff에서 보이는 추가 줄바꿈은 괜찮지만, 실제 파일에서 불필요한 빈 줄이 쌓이지 않도록 전체 포맷팅 (ktlint apply)을 추천.
🔴 문제점:
- 없음. 글로벌 익셉션 처리나 ApiResponse는 리포지토리 레이어와 무관하며, 이 변경은 안전한 JPA 메서드 추가로 보임.
YangHJ2415
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* feat(be): userChat service,controller,SSE 추가 * feat(be) : controller,service,repository 팀 스타일에 맞게 수정
목표
(1) 가이드–사용자 매칭 후 “채팅하기”를 누르면 두 사람이 같은 방에 동시에 입장
(2) STOMP 없이 SSE + REST 범위조회로 MVP 동작
(3) MVP 간소화: 같은 가이드–사용자 페어는 한 개의 방을 재사용(유니크 제약)
DTO,예외처리 등 추후 추가 예정
현재 1단계 작업 완성이고, 2단계에서 WebSocket,Stomp 추가 예정