-
Notifications
You must be signed in to change notification settings - Fork 1
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
[IDLE-423] soft-delete가 적용된 즐겨찾기 entity에서, 즐겨찾기 해제 후 재설정 시 발생하는 에러 해결 #187
Conversation
Walkthrough
Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant JobPostingFavoriteFacadeService
participant JobPostingFavoriteService
Client->>JobPostingFavoriteFacadeService: createJobPostingFavorite(jobPostingId, carerId)
JobPostingFavoriteFacadeService->>JobPostingFavoriteService: findByJobPostingIdAndCarerId(jobPostingId, carerId)
alt 즐겨찾기 발견
JobPostingFavoriteService-->>JobPostingFavoriteFacadeService: ExistingFavorite
JobPostingFavoriteFacadeService->>ExistingFavorite: active()
else 즐겨찾기 없음
JobPostingFavoriteFacadeService->>JobPostingFavoriteService: create(jobPostingId, carerId)
JobPostingFavoriteService-->>JobPostingFavoriteFacadeService: NewFavorite
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 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
Documentation and Community
|
|
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
🧹 Outside diff range and nitpick comments (1)
idle-application/src/main/kotlin/com/swm/idle/application/jobposting/facade/JobPostingFavoriteFacadeService.kt (1)
22-27
: 변경 사항이 PR 목표를 잘 달성했습니다.이 변경은 소프트 삭제된 즐겨찾기 엔티티를 다시 추가할 때 발생하는 오류를 해결하는 데 효과적입니다. 기존 즐겨찾기를 확인하고 필요한 경우 재활성화하는 로직이 잘 구현되었습니다.
다음과 같은 개선 사항을 고려해 보시기 바랍니다:
- 예외 처리:
findByJobPostingIdAndCarerId
메서드가 실패할 경우에 대한 예외 처리를 추가하는 것이 좋습니다.- 로깅: 즐겨찾기가 재활성화되거나 새로 생성될 때 로그를 추가하면 디버깅과 모니터링에 도움이 될 것입니다.
- 트랜잭션 처리: 데이터베이스 작업이 원자적으로 수행되도록 트랜잭션 처리를 고려해 보세요.
아래는 이러한 개선 사항을 반영한 코드 예시입니다:
@Transactional fun createJobPostingFavorite( jobPostingId: UUID, carerId: UUID, jobPostingType: JobPostingType, ) { try { val existingFavorite = jobPostingFavoriteService.findByJobPostingIdAndCarerId( jobPostingId = jobPostingId, carerId = carerId, ) if (existingFavorite != null) { existingFavorite.active() logger.info("Reactivated existing favorite for jobPosting: $jobPostingId, carer: $carerId") } else { jobPostingFavoriteService.create( jobPostingId = jobPostingId, carerId = carerId, jobPostingType = jobPostingType, ) logger.info("Created new favorite for jobPosting: $jobPostingId, carer: $carerId") } } catch (e: Exception) { logger.error("Error creating/reactivating favorite for jobPosting: $jobPostingId, carer: $carerId", e) throw e } }이 변경 사항에 대해 어떻게 생각하시나요?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- idle-application/src/main/kotlin/com/swm/idle/application/jobposting/facade/JobPostingFavoriteFacadeService.kt (1 hunks)
1. 📄 Summary
해결책
-> 즐겨찾기 생성 로직에서, 기존에 생성된 즐겨찾기 객체가 테이블에 존재하는 경우 이를 재 활성화 하도록 로직을 분기하여 처리했습니다.
Summary by CodeRabbit