-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 다른 사용자 인증 기록 조회 API #184
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
📝 Walkthrough워크스루(Walkthrough)다른 사용자의 인증 기록을 조회하는 새로운 API 엔드포인트를 추가합니다. 사용자 공개 설정을 확인하여 공개 사용자인 경우만 인증 기록을 반환하고, 비공개 사용자인 경우 빈 목록을 반환합니다. 페이지네이션을 지원합니다. 변경사항(Changes)
시퀀스 다이어그램(Sequence Diagram)sequenceDiagram
participant Client
participant UserController
participant VerificationService
participant UserRepository
participant VerificationRepository
Client->>UserController: GET /api/v1/user/{userId}/verifications/history<br/>(page, size)
activate UserController
Note over UserController: Input validation:<br/>@Positive userId<br/>@Min(1) page, size<br/>@Max(100) size
UserController->>VerificationService: getOtherUserVerificationHistory(userId, page-1, size)
deactivate UserController
activate VerificationService
VerificationService->>UserRepository: findById(userId)
activate UserRepository
UserRepository-->>VerificationService: User or UserNotFound
deactivate UserRepository
alt User Not Found
VerificationService-->>Client: Exception: USER_NOT_FOUND
else User Found
alt User is Private (isPublic = false)
rect rgba(200, 100, 100, 0.3)
Note over VerificationService: Private Account<br/>Return empty verification list
VerificationService->>VerificationService: Return OtherUserHistoryResponse<br/>(isPublic: false, nickname, empty verifications)
end
else User is Public (isPublic = true)
rect rgba(100, 150, 150, 0.3)
Note over VerificationService: Public Account<br/>Fetch COMPLETED verifications
VerificationService->>VerificationRepository: findCompletedVerifications(userId, page, size)
activate VerificationRepository
VerificationRepository-->>VerificationService: Slice<Verification>
deactivate VerificationRepository
VerificationService->>VerificationService: Map to HistoryDto
VerificationService->>VerificationService: Return OtherUserHistoryResponse<br/>(isPublic: true, nickname, verifications)
end
end
VerificationService-->>Client: ApiResponse<OtherUserHistoryResponse>
end
deactivate VerificationService
코드 리뷰 난이도 평가(Estimated Code Review Effort)🎯 3 (보통) | ⏱️ ~20분 사유: 세 개 파일에 걸친 일관된 기능 추가로, 엔드포인트 검증, DTO 구조, 서비스 로직이 명확합니다. 다만 프라이버시 로직, 페이지네이션 처리, 예외 처리를 꼼꼼히 확인해야 합니다. 관련 PR 제안(Possibly Related PRs)
시(Poem)
개선 제안사항1. 미사용 Import 정리위치: 2. DTO 필드명 일관성 검토위치: 3. 서비스 계층 로직 명확화위치: findByUserIdAndStatusAndNotBlocked(userId, Status.COMPLETED, page, size)4. 테스트 커버리지 확인위치: 전체 기능
칭찬: 기능 요구사항에 충실하고, 입력 검증과 프라이버시 로직이 잘 구현되어 있습니다! 👍 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 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.
Actionable comments posted: 0
🧹 Nitpick comments (2)
src/main/java/com/hrr/backend/domain/verification/service/VerificationServiceImpl.java (1)
483-501: 비공개 계정 처리가 올바르게 구현되었습니다.사용자의 프라이버시를 존중하는 로직이 잘 구현되어 있고,
isPublic=false와 함께 빈 배열을 반환하는 것이 적절합니다. 로그도 디버깅에 유용하겠네요.다만, Line 499에서
Page.empty()를 사용하는 부분은 동작에는 문제가 없지만, 코드베이스의 다른 곳에서 일관되게Slice를 사용하는 것과 비교하면 의미론적으로 약간 불일치합니다.🔎 더 일관된 코드를 위한 선택적 개선안
Page.empty()대신SliceImpl을 사용하면 Slice 개념과 더 일관성을 유지할 수 있습니다:+ Pageable pageable = PageRequest.of(page, size); + // 2. 비공개 계정 체크 if (!user.getIsPublic()) { log.info("User {} is private. Returning empty list.", userId); return VerificationResponseDto.OtherUserHistoryResponse.builder() .isPublic(false) .nickname(user.getNickname()) - .verifications(new SliceResponseDto<>(Page.empty())) + .verifications(new SliceResponseDto<>(new SliceImpl<>(Collections.emptyList(), pageable, false))) .build(); } // 3. 공개 계정 - Pageable pageable = PageRequest.of(page, size);추가로
Collections.emptyList()사용을 위한 import가 필요합니다:+import java.util.Collections;src/main/java/com/hrr/backend/domain/user/controller/UserController.java (1)
23-24: Line 24의 import가 사용되지 않는 것 같습니다.Line 23의
@Positiveimport는 새로운 엔드포인트에서 userId 검증에 사용되고 있지만, Line 24의Pageimport는 새로 추가된 코드에서 사용되지 않는 것으로 보입니다.🔎 사용하지 않는 import 제거
import jakarta.validation.Valid; import jakarta.validation.constraints.Positive; -import org.springframework.data.domain.Page; import org.springframework.validation.annotation.Validated;참고: IDE의 "Optimize Imports" 기능을 사용하면 자동으로 정리할 수 있습니다.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/main/java/com/hrr/backend/domain/user/controller/UserController.javasrc/main/java/com/hrr/backend/domain/verification/dto/VerificationResponseDto.javasrc/main/java/com/hrr/backend/domain/verification/service/VerificationService.javasrc/main/java/com/hrr/backend/domain/verification/service/VerificationServiceImpl.java
🔇 Additional comments (4)
src/main/java/com/hrr/backend/domain/verification/service/VerificationService.java (1)
68-84: 새로운 메서드 시그니처가 명확하고 일관성 있습니다.인터페이스에 추가된
getOtherUserVerificationHistory메서드는 기존getVerificationHistory메서드와 일관된 네이밍 패턴을 따르고 있으며, 반환 타입이 명확하게 다른 사용자 조회용 응답 DTO를 사용하고 있어 좋습니다. 주석도 목적을 잘 설명하고 있습니다.src/main/java/com/hrr/backend/domain/verification/dto/VerificationResponseDto.java (1)
177-192: DTO 설계가 적절합니다.
OtherUserHistoryResponse의 구조가 요구사항을 잘 반영하고 있습니다:
isPublic필드로 공개/비공개 상태를 명확히 전달- 기존
HistoryDto를 재사용하여 일관성 유지- Swagger 문서화가 잘 되어 있어 API 사용자에게 친절함
Builder 패턴 사용도 Good! 👍
src/main/java/com/hrr/backend/domain/verification/service/VerificationServiceImpl.java (1)
503-520: 공개 계정 처리 로직이 우수합니다.기존의
findVerificationHistoryByUser메서드를 재사용하여 일관성을 유지한 점이 훌륭합니다. 이는 PR 목표에서 언급한 "기존 로직 재사용"을 잘 따르고 있고, 중복 코드를 방지하는 좋은 패턴입니다.src/main/java/com/hrr/backend/domain/user/controller/UserController.java (1)
239-262: 엔드포인트 구현이 훌륭합니다!새로운 엔드포인트가 기존 패턴을 잘 따르고 있습니다:
- 입력 검증이 적절함 (
@Positive,@Min,@Max)- 1-based 페이지를 0-based로 변환하는 로직이 다른 엔드포인트와 일관됨
- Swagger 문서화가 명확하고 도움이 됨
- 서비스 레이어에 적절히 위임
비공개 사용자 처리를 서비스 레이어에서 담당하게 한 설계가 관심사의 분리(Separation of Concerns) 원칙을 잘 따르고 있네요. 멋집니다! 🎯
yc3697
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.
확인했습니다! API 명세도 마저 작성해주세요. 수고하셨습니다 ㅎㅎ
#️⃣ 연관된 이슈
✨ 작업 내용 (Summary)
✅ 변경 사항 체크리스트
🧪 테스트 결과
📸 스크린샷
💬 리뷰 요구사항
📎 참고 자료
Summary by CodeRabbit
릴리스 노트
✏️ Tip: You can customize this high-level summary in your review settings.