From e8a68b729953ad7a1d7ab87ded3e0e233ef128bb Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 7 Jan 2025 21:25:55 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20MemberAssociateEvent=20?= =?UTF-8?q?=EB=84=A4=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ociateRequirementUpdatedEventHandler.java} | 8 +++---- ...ociateRequirementUpdatedEventListener.java | 22 +++++++++++++++++++ .../MemberAssociateEventListener.java | 20 ----------------- .../AssociateRequirementUpdatedEvent.java | 3 +++ .../gdsc/domain/member/domain/Member.java | 6 ++--- .../member/domain/MemberAssociateEvent.java | 5 ----- .../application/MemberIntegrationTest.java | 9 ++++---- 7 files changed, 37 insertions(+), 36 deletions(-) rename src/main/java/com/gdschongik/gdsc/domain/member/application/handler/{MemberAssociateEventHandler.java => AssociateRequirementUpdatedEventHandler.java} (71%) create mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateEventListener.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateEvent.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/MemberAssociateEventHandler.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/AssociateRequirementUpdatedEventHandler.java similarity index 71% rename from src/main/java/com/gdschongik/gdsc/domain/member/application/handler/MemberAssociateEventHandler.java rename to src/main/java/com/gdschongik/gdsc/domain/member/application/handler/AssociateRequirementUpdatedEventHandler.java index f66bcf683..304f8638a 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/MemberAssociateEventHandler.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/AssociateRequirementUpdatedEventHandler.java @@ -1,8 +1,8 @@ package com.gdschongik.gdsc.domain.member.application.handler; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; +import com.gdschongik.gdsc.domain.member.domain.AssociateRequirementUpdatedEvent; import com.gdschongik.gdsc.domain.member.domain.Member; -import com.gdschongik.gdsc.domain.member.domain.MemberAssociateEvent; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.exception.ErrorCode; import lombok.RequiredArgsConstructor; @@ -12,12 +12,12 @@ @Slf4j @Component @RequiredArgsConstructor -public class MemberAssociateEventHandler { +public class AssociateRequirementUpdatedEventHandler { private final MemberRepository memberRepository; - public void advanceToAssociate(MemberAssociateEvent memberAssociateEvent) { + public void advanceToAssociate(AssociateRequirementUpdatedEvent associateRequirementUpdatedEvent) { Member member = memberRepository - .findById(memberAssociateEvent.memberId()) + .findById(associateRequirementUpdatedEvent.memberId()) .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); try { member.advanceToAssociate(); diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java new file mode 100644 index 000000000..9cbf51a37 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java @@ -0,0 +1,22 @@ +package com.gdschongik.gdsc.domain.member.application.listener; + +import com.gdschongik.gdsc.domain.member.application.handler.AssociateRequirementUpdatedEventHandler; +import com.gdschongik.gdsc.domain.member.domain.AssociateRequirementUpdatedEvent; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +@Component +@RequiredArgsConstructor +public class AssociateRequirementUpdatedEventListener { + + private final AssociateRequirementUpdatedEventHandler associateRequirementUpdatedEventHandler; + + @TransactionalEventListener( + phase = TransactionPhase.BEFORE_COMMIT, + classes = AssociateRequirementUpdatedEvent.class) + public void handleAssociateRequirementUpdatedEvent(AssociateRequirementUpdatedEvent event) { + associateRequirementUpdatedEventHandler.advanceToAssociate(event); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateEventListener.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateEventListener.java deleted file mode 100644 index 1e2e29bc4..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateEventListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gdschongik.gdsc.domain.member.application.listener; - -import com.gdschongik.gdsc.domain.member.application.handler.MemberAssociateEventHandler; -import com.gdschongik.gdsc.domain.member.domain.MemberAssociateEvent; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; -import org.springframework.transaction.event.TransactionPhase; -import org.springframework.transaction.event.TransactionalEventListener; - -@Component -@RequiredArgsConstructor -public class MemberAssociateEventListener { - - private final MemberAssociateEventHandler memberAssociateEventHandler; - - @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT, classes = MemberAssociateEvent.class) - public void handleMemberAssociateEvent(MemberAssociateEvent event) { - memberAssociateEventHandler.advanceToAssociate(event); - } -} diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java new file mode 100644 index 000000000..fe0bb038c --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java @@ -0,0 +1,3 @@ +package com.gdschongik.gdsc.domain.member.domain; + +public record AssociateRequirementUpdatedEvent(Long memberId) {} diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 5d41a079b..762b46852 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -175,7 +175,7 @@ public void updateBasicMemberInfo( associateRequirement.verifyInfo(); - registerEvent(new MemberAssociateEvent(this.id)); + registerEvent(new AssociateRequirementUpdatedEvent(this.id)); } /** @@ -192,7 +192,7 @@ public void completeUnivEmailVerification(String univEmail) { associateRequirement.verifyUniv(); - registerEvent(new MemberAssociateEvent(this.id)); + registerEvent(new AssociateRequirementUpdatedEvent(this.id)); } /** @@ -207,7 +207,7 @@ public void verifyDiscord(String discordUsername, String nickname) { associateRequirement.verifyDiscord(); - registerEvent(new MemberAssociateEvent(this.id)); + registerEvent(new AssociateRequirementUpdatedEvent(this.id)); } /** diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateEvent.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateEvent.java deleted file mode 100644 index d351add94..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateEvent.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.gdschongik.gdsc.domain.member.domain; - -public record MemberAssociateEvent(Long memberId) { - // TODO: 적절한 이름을 갖도록 수정 -} diff --git a/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java b/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java index e4de3b57b..626601738 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java @@ -3,10 +3,10 @@ import static com.gdschongik.gdsc.domain.member.domain.MemberRole.ASSOCIATE; import static org.assertj.core.api.Assertions.assertThat; -import com.gdschongik.gdsc.domain.member.application.handler.MemberAssociateEventHandler; +import com.gdschongik.gdsc.domain.member.application.handler.AssociateRequirementUpdatedEventHandler; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; +import com.gdschongik.gdsc.domain.member.domain.AssociateRequirementUpdatedEvent; import com.gdschongik.gdsc.domain.member.domain.Member; -import com.gdschongik.gdsc.domain.member.domain.MemberAssociateEvent; import com.gdschongik.gdsc.helper.IntegrationTest; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -15,7 +15,7 @@ @Slf4j public class MemberIntegrationTest extends IntegrationTest { @Autowired - private MemberAssociateEventHandler memberAssociateEventHandler; + private AssociateRequirementUpdatedEventHandler associateRequirementUpdatedEventHandler; @Autowired private MemberRepository memberRepository; @@ -26,7 +26,8 @@ public class MemberIntegrationTest extends IntegrationTest { Member member = createMember(); // when - memberAssociateEventHandler.advanceToAssociate(new MemberAssociateEvent(member.getId())); + associateRequirementUpdatedEventHandler.advanceToAssociate( + new AssociateRequirementUpdatedEvent(member.getId())); member = memberRepository.save(member); // then From ad2bb02c77682fe818b4a6d68d8b3ed77372d3d5 Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 14 Jan 2025 01:03:45 +0900 Subject: [PATCH 2/3] =?UTF-8?q?refactor:=20classes=20=EC=86=8D=EC=84=B1=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/AssociateRequirementUpdatedEventListener.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java index 9cbf51a37..74b907466 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java @@ -13,9 +13,7 @@ public class AssociateRequirementUpdatedEventListener { private final AssociateRequirementUpdatedEventHandler associateRequirementUpdatedEventHandler; - @TransactionalEventListener( - phase = TransactionPhase.BEFORE_COMMIT, - classes = AssociateRequirementUpdatedEvent.class) + @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) public void handleAssociateRequirementUpdatedEvent(AssociateRequirementUpdatedEvent event) { associateRequirementUpdatedEventHandler.advanceToAssociate(event); } From 138f3ac0506c376507b5cb263726b87d7ab89c6c Mon Sep 17 00:00:00 2001 From: "chosw1002@naver.com" Date: Tue, 14 Jan 2025 01:06:01 +0900 Subject: [PATCH 3/3] =?UTF-8?q?rename:=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=EC=97=90=20prefix=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ociateRequirementUpdatedEventHandler.java} | 8 ++++---- ...ociateRequirementUpdatedEventListener.java | 20 ------------------- ...ociateRequirementUpdatedEventListener.java | 20 +++++++++++++++++++ .../AssociateRequirementUpdatedEvent.java | 3 --- .../gdsc/domain/member/domain/Member.java | 6 +++--- ...emberAssociateRequirementUpdatedEvent.java | 3 +++ .../application/MemberIntegrationTest.java | 10 +++++----- 7 files changed, 35 insertions(+), 35 deletions(-) rename src/main/java/com/gdschongik/gdsc/domain/member/application/handler/{AssociateRequirementUpdatedEventHandler.java => MemberAssociateRequirementUpdatedEventHandler.java} (70%) delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateRequirementUpdatedEventListener.java delete mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java create mode 100644 src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateRequirementUpdatedEvent.java diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/AssociateRequirementUpdatedEventHandler.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/MemberAssociateRequirementUpdatedEventHandler.java similarity index 70% rename from src/main/java/com/gdschongik/gdsc/domain/member/application/handler/AssociateRequirementUpdatedEventHandler.java rename to src/main/java/com/gdschongik/gdsc/domain/member/application/handler/MemberAssociateRequirementUpdatedEventHandler.java index 304f8638a..356c48b4d 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/AssociateRequirementUpdatedEventHandler.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/handler/MemberAssociateRequirementUpdatedEventHandler.java @@ -1,8 +1,8 @@ package com.gdschongik.gdsc.domain.member.application.handler; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; -import com.gdschongik.gdsc.domain.member.domain.AssociateRequirementUpdatedEvent; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.member.domain.MemberAssociateRequirementUpdatedEvent; import com.gdschongik.gdsc.global.exception.CustomException; import com.gdschongik.gdsc.global.exception.ErrorCode; import lombok.RequiredArgsConstructor; @@ -12,12 +12,12 @@ @Slf4j @Component @RequiredArgsConstructor -public class AssociateRequirementUpdatedEventHandler { +public class MemberAssociateRequirementUpdatedEventHandler { private final MemberRepository memberRepository; - public void advanceToAssociate(AssociateRequirementUpdatedEvent associateRequirementUpdatedEvent) { + public void advanceToAssociate(MemberAssociateRequirementUpdatedEvent memberAssociateRequirementUpdatedEvent) { Member member = memberRepository - .findById(associateRequirementUpdatedEvent.memberId()) + .findById(memberAssociateRequirementUpdatedEvent.memberId()) .orElseThrow(() -> new CustomException(ErrorCode.MEMBER_NOT_FOUND)); try { member.advanceToAssociate(); diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java deleted file mode 100644 index 74b907466..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/AssociateRequirementUpdatedEventListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.gdschongik.gdsc.domain.member.application.listener; - -import com.gdschongik.gdsc.domain.member.application.handler.AssociateRequirementUpdatedEventHandler; -import com.gdschongik.gdsc.domain.member.domain.AssociateRequirementUpdatedEvent; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; -import org.springframework.transaction.event.TransactionPhase; -import org.springframework.transaction.event.TransactionalEventListener; - -@Component -@RequiredArgsConstructor -public class AssociateRequirementUpdatedEventListener { - - private final AssociateRequirementUpdatedEventHandler associateRequirementUpdatedEventHandler; - - @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) - public void handleAssociateRequirementUpdatedEvent(AssociateRequirementUpdatedEvent event) { - associateRequirementUpdatedEventHandler.advanceToAssociate(event); - } -} diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateRequirementUpdatedEventListener.java b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateRequirementUpdatedEventListener.java new file mode 100644 index 000000000..9ace8f599 --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/member/application/listener/MemberAssociateRequirementUpdatedEventListener.java @@ -0,0 +1,20 @@ +package com.gdschongik.gdsc.domain.member.application.listener; + +import com.gdschongik.gdsc.domain.member.application.handler.MemberAssociateRequirementUpdatedEventHandler; +import com.gdschongik.gdsc.domain.member.domain.MemberAssociateRequirementUpdatedEvent; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.transaction.event.TransactionPhase; +import org.springframework.transaction.event.TransactionalEventListener; + +@Component +@RequiredArgsConstructor +public class MemberAssociateRequirementUpdatedEventListener { + + private final MemberAssociateRequirementUpdatedEventHandler memberAssociateRequirementUpdatedEventHandler; + + @TransactionalEventListener(phase = TransactionPhase.BEFORE_COMMIT) + public void handleAssociateRequirementUpdatedEvent(MemberAssociateRequirementUpdatedEvent event) { + memberAssociateRequirementUpdatedEventHandler.advanceToAssociate(event); + } +} diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java deleted file mode 100644 index fe0bb038c..000000000 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/AssociateRequirementUpdatedEvent.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.gdschongik.gdsc.domain.member.domain; - -public record AssociateRequirementUpdatedEvent(Long memberId) {} diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java index 762b46852..7f3057d00 100644 --- a/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/Member.java @@ -175,7 +175,7 @@ public void updateBasicMemberInfo( associateRequirement.verifyInfo(); - registerEvent(new AssociateRequirementUpdatedEvent(this.id)); + registerEvent(new MemberAssociateRequirementUpdatedEvent(this.id)); } /** @@ -192,7 +192,7 @@ public void completeUnivEmailVerification(String univEmail) { associateRequirement.verifyUniv(); - registerEvent(new AssociateRequirementUpdatedEvent(this.id)); + registerEvent(new MemberAssociateRequirementUpdatedEvent(this.id)); } /** @@ -207,7 +207,7 @@ public void verifyDiscord(String discordUsername, String nickname) { associateRequirement.verifyDiscord(); - registerEvent(new AssociateRequirementUpdatedEvent(this.id)); + registerEvent(new MemberAssociateRequirementUpdatedEvent(this.id)); } /** diff --git a/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateRequirementUpdatedEvent.java b/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateRequirementUpdatedEvent.java new file mode 100644 index 000000000..5b0dcdefe --- /dev/null +++ b/src/main/java/com/gdschongik/gdsc/domain/member/domain/MemberAssociateRequirementUpdatedEvent.java @@ -0,0 +1,3 @@ +package com.gdschongik.gdsc.domain.member.domain; + +public record MemberAssociateRequirementUpdatedEvent(Long memberId) {} diff --git a/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java b/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java index 626601738..dc03c0d97 100644 --- a/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java +++ b/src/test/java/com/gdschongik/gdsc/domain/member/application/MemberIntegrationTest.java @@ -3,10 +3,10 @@ import static com.gdschongik.gdsc.domain.member.domain.MemberRole.ASSOCIATE; import static org.assertj.core.api.Assertions.assertThat; -import com.gdschongik.gdsc.domain.member.application.handler.AssociateRequirementUpdatedEventHandler; +import com.gdschongik.gdsc.domain.member.application.handler.MemberAssociateRequirementUpdatedEventHandler; import com.gdschongik.gdsc.domain.member.dao.MemberRepository; -import com.gdschongik.gdsc.domain.member.domain.AssociateRequirementUpdatedEvent; import com.gdschongik.gdsc.domain.member.domain.Member; +import com.gdschongik.gdsc.domain.member.domain.MemberAssociateRequirementUpdatedEvent; import com.gdschongik.gdsc.helper.IntegrationTest; import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -15,7 +15,7 @@ @Slf4j public class MemberIntegrationTest extends IntegrationTest { @Autowired - private AssociateRequirementUpdatedEventHandler associateRequirementUpdatedEventHandler; + private MemberAssociateRequirementUpdatedEventHandler memberAssociateRequirementUpdatedEventHandler; @Autowired private MemberRepository memberRepository; @@ -26,8 +26,8 @@ public class MemberIntegrationTest extends IntegrationTest { Member member = createMember(); // when - associateRequirementUpdatedEventHandler.advanceToAssociate( - new AssociateRequirementUpdatedEvent(member.getId())); + memberAssociateRequirementUpdatedEventHandler.advanceToAssociate( + new MemberAssociateRequirementUpdatedEvent(member.getId())); member = memberRepository.save(member); // then