♻️ refactor: Observer 패턴을 적용하여 회원 탈퇴 로직 개선#258
Merged
leeseojun34 merged 1 commit intoSep 13, 2025
Merged
Conversation
[문제] - 기존의 회원 탈퇴(`withdraw`) 로직은 MemberService가 GroupCommandService, ScheduleCommandService 들을 직접 호출하는 구조 - 서비스 간의 의존성이 높아져 코드의 유연성과 확장성이 저하되는 문제 발생 [접근] Spring의 ApplicationEventPublisher를 사용하여 Observer 패턴을 적용 [변경 사항] - MemberWithdrawalEvent: 회원 탈퇴 시 발행할 이벤트를 정의 - MemberService: ApplicationEventPublisher를 주입받아, 회원 탈퇴가 발생하면 MemberWithdrawalEvent를 발행하도록 withdraw 메서드를 변경, GroupCommandService와 ScheduleCommandService에 대한 직접적인 의존성을 제거 - Group/ScheduleCommandService: @eventlistener 어노테이션을 사용하여 MemberWithdrawalEvent를 구독하는 메서드를 각 서비스에 추가, 각 서비스는 회원 탈퇴 이벤트를 감지하여 그룹 탈퇴 처리, 일정 관리자 위임 등 관련된 후속 작업을 독립적으로 수행 향후 회원 탈퇴 시 추가적인 작업이 필요할 경우 다른 서비스 코드의 수정 없이 새로운 리스너를 추가하는 것만으로 간단하게 확장할 수 있음
Collaborator
|
굿굿 |
june3780
approved these changes
Sep 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
✅ 관련 이슈
🛠️ 작업 내용
회원 탈퇴 로직의 서비스 간 결합도를 낮추기 위해 Observer 패턴을 적용하여 리팩토링을 진행
AS-IS
TO-BE
📸 스크린샷
withdraw.sql 상황에서 5a 사용자가 회원 탈퇴
