diff --git a/services/creator/src/main/java/kr/magicbox/creator/application/service/certification/ReviewCreatorCertificationService.java b/services/creator/src/main/java/kr/magicbox/creator/application/service/certification/ReviewCreatorCertificationService.java index 09d45430..f8dace37 100644 --- a/services/creator/src/main/java/kr/magicbox/creator/application/service/certification/ReviewCreatorCertificationService.java +++ b/services/creator/src/main/java/kr/magicbox/creator/application/service/certification/ReviewCreatorCertificationService.java @@ -37,18 +37,25 @@ public void reviewCreatorCertification(ReviewCreatorCertificationCommand command certificationRepositoryPort.update(certification); if (certification.isApproved()) { - createCreator(certification); - eventRepositoryPort.save(buildApprovedEvent(certification)); + Creator creator = createCreator(certification); + eventRepositoryPort.save(buildApprovedEvent(certification, creator)); } else { eventRepositoryPort.save(buildRejectedEvent(certification)); } } - private CreatorCertificationApprovedEvent buildApprovedEvent(CreatorCertification certification) { + private CreatorCertificationApprovedEvent buildApprovedEvent(CreatorCertification certification, Creator creator) { return CreatorCertificationApprovedEvent.builder() .userId(certification.getUserId()) + .creatorId(creator.getId()) .certificationId(certification.getId()) + .nickname(creator.getNicknameValue()) + .tagline(creator.getTagline()) + .profileImageUrl(creator.getProfileImageUrl()) + .introduction(creator.getIntroduction()) + .genres(creator.getGenres()) + .status(creator.getStatus()) .occurredAt(certification.getResult().reviewedAt()) .build(); } @@ -62,7 +69,7 @@ private CreatorCertificationRejectedEvent buildRejectedEvent(CreatorCertificatio .build(); } - private void createCreator(CreatorCertification certification) { + private Creator createCreator(CreatorCertification certification) { if (creatorRepositoryPort.existsByUserId(certification.getUserId())) { throw new CreatorAlreadyExistsException(); } @@ -75,5 +82,7 @@ private void createCreator(CreatorCertification certification) { .build(); creatorRepositoryPort.save(creator); + return creatorRepositoryPort.findByUserId(certification.getUserId()) + .orElseThrow(() -> new IllegalStateException("저장된 크리에이터를 찾을 수 없습니다.")); } } diff --git a/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorCertificationApprovedEvent.java b/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorCertificationApprovedEvent.java index e77d1bf3..b5142326 100644 --- a/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorCertificationApprovedEvent.java +++ b/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorCertificationApprovedEvent.java @@ -1,16 +1,27 @@ package kr.magicbox.creator.domain.event; import com.fasterxml.jackson.annotation.JsonProperty; +import kr.magicbox.creator.domain.enums.CreatorStatus; +import kr.magicbox.creator.domain.enums.MagicGenre; import kr.magicbox.creator.domain.vo.CreatorCertificationId; +import kr.magicbox.creator.domain.vo.CreatorId; import kr.magicbox.creator.domain.vo.UserId; import lombok.Builder; import java.time.Instant; +import java.util.Set; @Builder public record CreatorCertificationApprovedEvent( @JsonProperty("user_id") UserId userId, + @JsonProperty("creator_id") CreatorId creatorId, @JsonProperty("certification_id") CreatorCertificationId certificationId, + @JsonProperty("nickname") String nickname, + @JsonProperty("tagline") String tagline, + @JsonProperty("profile_image_url") String profileImageUrl, + @JsonProperty("introduction") String introduction, + @JsonProperty("genres") Set genres, + @JsonProperty("status") CreatorStatus status, @JsonProperty("occurred_at") Instant occurredAt ) implements CreatorDomainEvent { diff --git a/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorDomainEventType.java b/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorDomainEventType.java index 6f614ff9..9a39f8cf 100644 --- a/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorDomainEventType.java +++ b/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorDomainEventType.java @@ -9,6 +9,7 @@ public enum CreatorDomainEventType { CREATOR_CERTIFICATION_APPROVED("creator-certification-approved"), CREATOR_CERTIFICATION_REJECTED("creator-certification-rejected"), + CREATOR_PROFILE_UPDATED("creator-profile-updated"), CREATOR_REVOKED("creator-revoked"), CREATOR_UNBANNED("creator-unbanned"); diff --git a/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorProfileUpdatedEvent.java b/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorProfileUpdatedEvent.java new file mode 100644 index 00000000..c3169343 --- /dev/null +++ b/services/creator/src/main/java/kr/magicbox/creator/domain/event/CreatorProfileUpdatedEvent.java @@ -0,0 +1,36 @@ +package kr.magicbox.creator.domain.event; + +import com.fasterxml.jackson.annotation.JsonProperty; +import kr.magicbox.creator.domain.enums.MagicGenre; +import kr.magicbox.creator.domain.vo.CreatorId; +import lombok.Builder; + +import java.time.Instant; +import java.util.Set; + +@Builder +public record CreatorProfileUpdatedEvent( + @JsonProperty("creator_id") CreatorId creatorId, + @JsonProperty("before") ProfileSnapshot before, + @JsonProperty("after") ProfileSnapshot after, + @JsonProperty("occurred_at") Instant occurredAt +) implements CreatorDomainEvent { + + public record ProfileSnapshot( + @JsonProperty("nickname") String nickname, + @JsonProperty("tagline") String tagline, + @JsonProperty("profile_image_url") String profileImageUrl, + @JsonProperty("introduction") String introduction, + @JsonProperty("genres") Set genres + ) {} + + @Override + public String key() { + return creatorId.value().toString(); + } + + @Override + public CreatorDomainEventType eventType() { + return CreatorDomainEventType.CREATOR_PROFILE_UPDATED; + } +}