Skip to content
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

refactor: MemberAssociateEvent 네이밍 변경 #837

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

클래스는 지정 안해줘도 될 것 같아요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그렇겠네요 제거할게요~

public void handleAssociateRequirementUpdatedEvent(AssociateRequirementUpdatedEvent event) {
associateRequirementUpdatedEventHandler.advanceToAssociate(event);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.gdschongik.gdsc.domain.member.domain;

public record AssociateRequirementUpdatedEvent(Long memberId) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Member prefix가 붙는게 좋을 것 같은데 어떻게 생각하시나요?
MemberAssociateRequirementUpdatedEvent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋아요 정회원 관련 이벤트들도 이미 다 붙어있으니 여기도 붙이는게 좋겠어요

Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public void updateBasicMemberInfo(

associateRequirement.verifyInfo();

registerEvent(new MemberAssociateEvent(this.id));
registerEvent(new AssociateRequirementUpdatedEvent(this.id));
}

/**
Expand All @@ -192,7 +192,7 @@ public void completeUnivEmailVerification(String univEmail) {

associateRequirement.verifyUniv();

registerEvent(new MemberAssociateEvent(this.id));
registerEvent(new AssociateRequirementUpdatedEvent(this.id));
}

/**
Expand All @@ -207,7 +207,7 @@ public void verifyDiscord(String discordUsername, String nickname) {

associateRequirement.verifyDiscord();

registerEvent(new MemberAssociateEvent(this.id));
registerEvent(new AssociateRequirementUpdatedEvent(this.id));
}

/**
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,7 +15,7 @@
@Slf4j
public class MemberIntegrationTest extends IntegrationTest {
@Autowired
private MemberAssociateEventHandler memberAssociateEventHandler;
private AssociateRequirementUpdatedEventHandler associateRequirementUpdatedEventHandler;

@Autowired
private MemberRepository memberRepository;
Expand All @@ -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
Expand Down
Loading