feat(connection): 현재 connection attempt 조회 메서드 구현#49
Conversation
Walkthrough이번 변경사항은 사용자 연결 시도의 최신 정보를 조회하기 위한 인터페이스와 서비스 기능을 추가합니다. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Service as ConnectionQueryService
participant Repo as ConnectionAttemptRepository
participant Adapter as ConnectionAttemptPersistenceAdapter
participant JPA as ConnectionAttemptJpaRepository
Client->>Service: invoke(Command)
Service->>Repo: findLatestConnectionAttempt(userId)
Repo->>Adapter: call adapter method
Adapter->>JPA: findFirstByUserIdOrderByCreatedAtDesc(userId)
JPA-->>Adapter: ConnectionAttemptJpaEntity / null
Adapter-->>Repo: 도메인 ConnectionAttempt 반환
Repo-->>Service: ConnectionAttempt 혹은 null
alt ConnectionAttempt 존재
Service-->>Client: Result(ConnectionAttempt)
else 존재하지 않음
Service-->>Client: NotFoundException 발생
end
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
⏰ Context from checks skipped due to timeout of 90000ms (1)
🔇 Additional comments (2)
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
c31e001 to
f20d543
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
application/src/main/kotlin/com/threedays/application/connection/service/ConnectionQueryService.kt (1)
9-11: 의존성 은닉성 개선이 필요합니다.서비스 클래스의 구현은 전반적으로 잘 되어 있습니다만, 의존성 주입 부분에서 개선이 필요합니다. 현재
connectionAttemptRepository가val로 선언되어 있어 외부에서 접근 가능한 공개 프로퍼티가 되었습니다. 의존성은 일반적으로 캡슐화하는 것이 좋은 관행입니다.다음과 같이 수정하는 것을 권장합니다:
-class ConnectionQueryService( - val connectionAttemptRepository: ConnectionAttemptRepository, -) : GetCurrentConnectionAttempt { +class ConnectionQueryService( + private val connectionAttemptRepository: ConnectionAttemptRepository, +) : GetCurrentConnectionAttempt {application/src/main/kotlin/com/threedays/application/connection/port/inbound/GetCurrentConnection.kt (1)
1-20: 인터페이스 설계가 명확하고 적절합니다.코드는 잘 구조화되어 있으며 헥사고날 아키텍처 패턴을 적절하게 따르고 있습니다. 다만 몇 가지 개선할 점이 있습니다:
파일명(
GetCurrentConnection.kt)과 인터페이스명(GetCurrentConnectionAttempt)이 일치하지 않습니다. 일관성을 위해 둘 중 하나를 수정하는 것이 좋겠습니다.인터페이스와 메서드에 KDoc 문서화가 없습니다. 각 매개변수의 목적과 동작 방식에 대한 문서를 추가하면 코드의 가독성과 유지보수성이 향상될 것입니다.
Result클래스의connectionAttempt속성이 null이 될 수 없습니다. 사용자에 대한 연결 시도가 없는 경우를 처리하는 방법을 고려해야 합니다.data class Result( val connectionAttempt: ConnectionAttempt?, )또는 빈 목록을 반환하는 방식도 고려할 수 있습니다:
data class Result( val connectionAttempts: List<ConnectionAttempt> = emptyList(), )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
application/src/main/kotlin/com/threedays/application/connection/port/inbound/GetCurrentConnection.kt(1 hunks)application/src/main/kotlin/com/threedays/application/connection/service/ConnectionQueryService.kt(1 hunks)domain/src/main/kotlin/com/threedays/domain/connection/repository/ConnectionAttemptRepository.kt(1 hunks)infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/adapter/ConnectionAttemptPersistenceAdapter.kt(2 hunks)infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/repository/ConnectionAttemptJpaRepository.kt(1 hunks)
🔇 Additional comments (4)
infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/repository/ConnectionAttemptJpaRepository.kt (1)
9-11: Spring Data JPA 메서드 구현이 잘 되었습니다!메서드 이름이 Spring Data JPA 명명 규칙을 정확히 따르고 있으며, 특정 사용자의 가장 최근 연결 시도를 조회하는 기능을 효과적으로 구현했습니다. 반환 타입이 nullable로 설정된 것도 사용자에게 연결 시도가 없을 수 있는 경우를 고려한 좋은 설계입니다.
domain/src/main/kotlin/com/threedays/domain/connection/repository/ConnectionAttemptRepository.kt (1)
4-4: 도메인 계층의 리포지토리 인터페이스 확장이 잘 구현되었습니다!User.Id 타입을 매개변수로 사용하고 도메인 엔티티인 ConnectionAttempt를 반환하는 메서드 시그니처는 도메인 주도 설계 원칙에 잘 부합합니다. 도메인 타입을 사용하여 영속성 계층의 구현 세부사항(raw UUID)을 도메인 계층에서 숨기는 추상화가 잘 되어 있습니다.
Also applies to: 8-10
infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/adapter/ConnectionAttemptPersistenceAdapter.kt (1)
5-5: 어댑터 구현이 헥사고날 아키텍처 패턴을 잘 따르고 있습니다!도메인 계층의 User.Id를 받아 JPA 리포지토리 메서드에 필요한 UUID로 변환하고, 결과를 다시 도메인 엔티티로 매핑하는 구현이 깔끔합니다. 안전 호출 연산자(
?.)를 사용해 결과가 없을 경우 null을 반환하도록 처리한 부분도 적절합니다. 영속성 계층과 도메인 계층을 잘 분리한 좋은 구현입니다.Also applies to: 17-19
application/src/main/kotlin/com/threedays/application/connection/service/ConnectionQueryService.kt (1)
13-17: 유스케이스 구현이 잘 되었습니다!repository를 통해 최신 연결 시도를 조회하고, 결과가 없을 경우 적절한 예외를 발생시키는 구현이 명확합니다. Elvis 연산자(
?:)를 사용한 null 체크 처리도 코틀린 관용적인 방식으로 잘 작성되었습니다. 도메인 엔티티를 애플리케이션 레이어의 Result 객체로 변환하는 부분도 깔끔하게 처리되었습니다.
| @@ -13,6 +14,10 @@ import kotlin.jvm.optionals.getOrNull | |||
| class ConnectionAttemptPersistenceAdapter( | |||
There was a problem hiding this comment.
Transactional 빼버릴까요? ㅋㅋ 단순 읽기작업에 트랜잭션이 나가는게 생각보다 성능에 유의미한 영향이 있다더라구요
https://tech.kakaopay.com/post/jpa-transactional-bri/
There was a problem hiding this comment.
f20d543 to
e31e9e1
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
domain/src/testFixtures/kotlin/com/threedays/domain/connection/repository/ConnectionAttemptRepositorySpy.kt (1)
8-11: 테스트 스파이의 메서드 호출 추적 기능 추가 제안테스트 스파이의 일반적인 목적은 메서드 호출을 추적하는 것입니다. 이 메서드가 호출되었는지와 어떤 매개변수로 호출되었는지 추적하는 기능을 추가하는 것이 좋을 것 같습니다.
class ConnectionAttemptRepositorySpy : ConnectionAttemptRepository, RepositorySpyBase<ConnectionAttempt, ConnectionAttempt.Id>() { + val findLatestConnectionAttemptCalls = mutableListOf<User.Id>() + override fun findLatestConnectionAttempt(userId: User.Id): ConnectionAttempt? { + findLatestConnectionAttemptCalls.add(userId) return entities.values .filter { it.userId == userId } .maxByOrNull { it.createdAt } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
application/src/main/kotlin/com/threedays/application/connection/port/inbound/GetCurrentConnection.kt(1 hunks)application/src/main/kotlin/com/threedays/application/connection/service/ConnectionQueryService.kt(1 hunks)domain/src/main/kotlin/com/threedays/domain/connection/repository/ConnectionAttemptRepository.kt(1 hunks)domain/src/testFixtures/kotlin/com/threedays/domain/connection/repository/ConnectionAttemptRepositorySpy.kt(1 hunks)infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/adapter/ConnectionAttemptPersistenceAdapter.kt(2 hunks)infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/repository/ConnectionAttemptJpaRepository.kt(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- application/src/main/kotlin/com/threedays/application/connection/service/ConnectionQueryService.kt
- infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/adapter/ConnectionAttemptPersistenceAdapter.kt
- infrastructure/persistence/src/main/kotlin/com/threedays/persistence/connection/repository/ConnectionAttemptJpaRepository.kt
- application/src/main/kotlin/com/threedays/application/connection/port/inbound/GetCurrentConnection.kt
- domain/src/main/kotlin/com/threedays/domain/connection/repository/ConnectionAttemptRepository.kt
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Run unit test and static analysis
e31e9e1 to
8aa4c4f
Compare
8aa4c4f to
8f70dd8
Compare
|




Summary by CodeRabbit