From 6a1112b2a4126e52e42c5882e08b947d9adf0166 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Tue, 16 Apr 2024 21:12:43 +0900 Subject: [PATCH 01/16] =?UTF-8?q?fix:=20dev=20&=20prod=20workflow=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#161)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd-dev.yml | 6 +++--- .github/workflows/cicd-prod.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/cicd-dev.yml b/.github/workflows/cicd-dev.yml index 9fa58f5..dd84dc8 100644 --- a/.github/workflows/cicd-dev.yml +++ b/.github/workflows/cicd-dev.yml @@ -43,7 +43,7 @@ jobs: with: username: ubuntu host: ${{ secrets.EC2_DEV_HOST }} - key: ${{ secrets.EC2_KEY }} + key: ${{ secrets.EC2_DEV_KEY }} port: ${{ secrets.EC2_PORT }} source: "./scripts/deploy.sh" target: "/home/ubuntu/" @@ -53,7 +53,7 @@ jobs: with: username: ubuntu host: ${{ secrets.EC2_DEV_HOST }} - key: ${{ secrets.EC2_KEY }} + key: ${{ secrets.EC2_DEV_KEY }} port: ${{ secrets.EC2_PORT }} source: "./docker-compose.yml" target: "/home/ubuntu/" @@ -71,7 +71,7 @@ jobs: with: username: ubuntu host: ${{ secrets.EC2_DEV_HOST }} - key: ${{ secrets.EC2_KEY }} + key: ${{ secrets.EC2_DEV_KEY }} script: | sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} chmod 777 ./scripts/deploy.sh diff --git a/.github/workflows/cicd-prod.yml b/.github/workflows/cicd-prod.yml index 248326b..63e46c9 100644 --- a/.github/workflows/cicd-prod.yml +++ b/.github/workflows/cicd-prod.yml @@ -43,7 +43,7 @@ jobs: with: username: ubuntu host: ${{ secrets.EC2_PROD_HOST }} - key: ${{ secrets.EC2_KEY }} + key: ${{ secrets.EC2_PROD_KEY }} port: ${{ secrets.EC2_PORT }} source: "./scripts/deploy.sh" target: "/home/ubuntu/" @@ -53,7 +53,7 @@ jobs: with: username: ubuntu host: ${{ secrets.EC2_PROD_HOST }} - key: ${{ secrets.EC2_KEY }} + key: ${{ secrets.EC2_PROD_KEY }} port: ${{ secrets.EC2_PORT }} source: "./docker-compose.yml" target: "/home/ubuntu/" @@ -71,7 +71,7 @@ jobs: with: username: ubuntu host: ${{ secrets.EC2_PROD_HOST }} - key: ${{ secrets.EC2_KEY }} + key: ${{ secrets.EC2_PROD_KEY }} script: | sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }} chmod 777 ./scripts/deploy.sh From cb8c1eb775345bbd9615857b15856f4a23e06a2e Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:09:14 +0900 Subject: [PATCH 02/16] =?UTF-8?q?del:=20=EB=B6=88=ED=95=84=EC=9A=94=20root?= =?UTF-8?q?=20=EC=9D=B8=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doorip-common/src/main/java/org/doorip/CommonRoot.java | 4 ---- doorip-domain/src/main/java/org/doorip/DomainRoot.java | 4 ---- doorip-external/src/main/java/org/doorip/ExternalRoot.java | 4 ---- 3 files changed, 12 deletions(-) delete mode 100644 doorip-common/src/main/java/org/doorip/CommonRoot.java delete mode 100644 doorip-domain/src/main/java/org/doorip/DomainRoot.java delete mode 100644 doorip-external/src/main/java/org/doorip/ExternalRoot.java diff --git a/doorip-common/src/main/java/org/doorip/CommonRoot.java b/doorip-common/src/main/java/org/doorip/CommonRoot.java deleted file mode 100644 index 86d06f6..0000000 --- a/doorip-common/src/main/java/org/doorip/CommonRoot.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.doorip; - -public interface CommonRoot { -} diff --git a/doorip-domain/src/main/java/org/doorip/DomainRoot.java b/doorip-domain/src/main/java/org/doorip/DomainRoot.java deleted file mode 100644 index c782f51..0000000 --- a/doorip-domain/src/main/java/org/doorip/DomainRoot.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.doorip; - -public interface DomainRoot { -} diff --git a/doorip-external/src/main/java/org/doorip/ExternalRoot.java b/doorip-external/src/main/java/org/doorip/ExternalRoot.java deleted file mode 100644 index bbd191c..0000000 --- a/doorip-external/src/main/java/org/doorip/ExternalRoot.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.doorip; - -public interface ExternalRoot { -} From 560b24fa2d8dd1edb1b080e220b55346e4b4bb68 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:12:41 +0900 Subject: [PATCH 03/16] =?UTF-8?q?chore:=20publisher=20&=20subscriber=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=B6=94=EA=B0=80=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- settings.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/settings.gradle b/settings.gradle index 7417e93..8fc3086 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,3 +3,6 @@ include 'doorip-api' include 'doorip-domain' include 'doorip-common' include 'doorip-external' +include 'doorip-event-publisher' +include 'doorip-event-subscriber' + From 6a3b92672bc9ca3b33481ff1051f63ad5326c727 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:12:58 +0900 Subject: [PATCH 04/16] =?UTF-8?q?chore:=20base=20package=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/doorip/config/FeignClientConfig.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doorip-external/src/main/java/org/doorip/config/FeignClientConfig.java b/doorip-external/src/main/java/org/doorip/config/FeignClientConfig.java index 1b41be6..5d85133 100644 --- a/doorip-external/src/main/java/org/doorip/config/FeignClientConfig.java +++ b/doorip-external/src/main/java/org/doorip/config/FeignClientConfig.java @@ -1,10 +1,9 @@ package org.doorip.config; -import org.doorip.ExternalRoot; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; @Configuration -@EnableFeignClients(basePackageClasses = ExternalRoot.class) +@EnableFeignClients(basePackages = "org.doorip") public class FeignClientConfig { } From 0616163b8b432e09463549461e80afcc57b1c68f Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:13:23 +0900 Subject: [PATCH 05/16] =?UTF-8?q?chore:=20event=20publisher=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=B6=94=EA=B0=80=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doorip-event-publisher/build.gradle | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doorip-event-publisher/build.gradle diff --git a/doorip-event-publisher/build.gradle b/doorip-event-publisher/build.gradle new file mode 100644 index 0000000..f15df54 --- /dev/null +++ b/doorip-event-publisher/build.gradle @@ -0,0 +1,12 @@ +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation project(path: ':doorip-common') +} + +bootJar { + enabled = false +} + +jar { + enabled = true +} \ No newline at end of file From 341028aa84337ab201e3001aff21bead4c72c58f Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:13:36 +0900 Subject: [PATCH 06/16] =?UTF-8?q?chore:=20event=20subscriber=20=EB=AA=A8?= =?UTF-8?q?=EB=93=88=20=EC=B6=94=EA=B0=80=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doorip-event-subscriber/build.gradle | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doorip-event-subscriber/build.gradle diff --git a/doorip-event-subscriber/build.gradle b/doorip-event-subscriber/build.gradle new file mode 100644 index 0000000..eedd44f --- /dev/null +++ b/doorip-event-subscriber/build.gradle @@ -0,0 +1,13 @@ +dependencies { + implementation 'org.springframework.boot:spring-boot-starter-web' + implementation project(path: ':doorip-common') + implementation project(path: ':doorip-external') +} + +bootJar { + enabled = false +} + +jar { + enabled = true +} \ No newline at end of file From 695feb41e9a5eef3b34b3ae65a241731972a4607 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:15:40 +0900 Subject: [PATCH 07/16] =?UTF-8?q?feat:=20sign=20up=20event=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/doorip/event/SignUpEvent.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doorip-common/src/main/java/org/doorip/event/SignUpEvent.java diff --git a/doorip-common/src/main/java/org/doorip/event/SignUpEvent.java b/doorip-common/src/main/java/org/doorip/event/SignUpEvent.java new file mode 100644 index 0000000..759ff51 --- /dev/null +++ b/doorip-common/src/main/java/org/doorip/event/SignUpEvent.java @@ -0,0 +1,13 @@ +package org.doorip.event; + +import org.doorip.message.EventMessage; + +public record SignUpEvent( + EventMessage eventMessage, + String name, + int count +) { + public static SignUpEvent of(EventMessage eventMessage, String name, int count) { + return new SignUpEvent(eventMessage, name, count); + } +} From 7132a8c365a8d9f4f4289a75785d92f6a0fb1240 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:16:17 +0900 Subject: [PATCH 08/16] =?UTF-8?q?feat:=20event=20publisher=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/doorip/publisher/EventPublisher.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 doorip-event-publisher/src/main/java/org/doorip/publisher/EventPublisher.java diff --git a/doorip-event-publisher/src/main/java/org/doorip/publisher/EventPublisher.java b/doorip-event-publisher/src/main/java/org/doorip/publisher/EventPublisher.java new file mode 100644 index 0000000..0b04840 --- /dev/null +++ b/doorip-event-publisher/src/main/java/org/doorip/publisher/EventPublisher.java @@ -0,0 +1,19 @@ +package org.doorip.publisher; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.doorip.event.SignUpEvent; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.stereotype.Component; + +@Slf4j +@RequiredArgsConstructor +@Component +public class EventPublisher { + private final ApplicationEventPublisher eventPublisher; + + public void publishSignUpEvent(SignUpEvent event) { + log.info("[publish] sign up event {}", event); + eventPublisher.publishEvent(event); + } +} From fba7b13b9a2f12f5d85dbafeaaafe896397fa50c Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:16:40 +0900 Subject: [PATCH 09/16] =?UTF-8?q?chore:=20async=20=EC=84=A4=EC=A0=95=20(#1?= =?UTF-8?q?60)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/doorip/config/AsyncConfig.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doorip-event-subscriber/src/main/java/org/doorip/config/AsyncConfig.java diff --git a/doorip-event-subscriber/src/main/java/org/doorip/config/AsyncConfig.java b/doorip-event-subscriber/src/main/java/org/doorip/config/AsyncConfig.java new file mode 100644 index 0000000..7cf6f0e --- /dev/null +++ b/doorip-event-subscriber/src/main/java/org/doorip/config/AsyncConfig.java @@ -0,0 +1,23 @@ +package org.doorip.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; + +import java.util.concurrent.Executor; + +@EnableAsync +@Configuration +public class AsyncConfig { + @Bean + public Executor threadPoolTaskExecutor() { + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); + executor.setCorePoolSize(3); + executor.setMaxPoolSize(30); + executor.setQueueCapacity(100); + executor.setThreadNamePrefix("async-executor-"); + executor.initialize(); + return executor; + } +} From 4ecc269e1dff009e480070490b88b45de9f8e544 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:17:19 +0900 Subject: [PATCH 10/16] =?UTF-8?q?feat:=20event=20subscriber=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../doorip/subscriber/EventSubscriber.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 doorip-event-subscriber/src/main/java/org/doorip/subscriber/EventSubscriber.java diff --git a/doorip-event-subscriber/src/main/java/org/doorip/subscriber/EventSubscriber.java b/doorip-event-subscriber/src/main/java/org/doorip/subscriber/EventSubscriber.java new file mode 100644 index 0000000..8c2681c --- /dev/null +++ b/doorip-event-subscriber/src/main/java/org/doorip/subscriber/EventSubscriber.java @@ -0,0 +1,26 @@ +package org.doorip.subscriber; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.doorip.event.SignUpEvent; +import org.doorip.message.EventMessage; +import org.doorip.openfeign.discord.DiscordMessageProvider; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +@Slf4j +@RequiredArgsConstructor +@Component +public class EventSubscriber { + private final DiscordMessageProvider discordMessageProvider; + + @Async + @EventListener + public void subscribeSignUpEvent(SignUpEvent event) { + log.info("[subscribe] sign up event {}", event); + EventMessage eventMessage = event.eventMessage(); + String message = String.format(eventMessage.getMessage(), event.name(), event.count()); + discordMessageProvider.sendMessage(message); + } +} From 11fb083ddc5300836b04433628c0895989a60d9c Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:17:39 +0900 Subject: [PATCH 11/16] =?UTF-8?q?chore:=20publisher=20&=20subscriber=20?= =?UTF-8?q?=EB=AA=A8=EB=93=88=20=EC=9D=98=EC=A1=B4=EC=84=B1=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doorip-api/build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doorip-api/build.gradle b/doorip-api/build.gradle index 73b4460..de4da41 100644 --- a/doorip-api/build.gradle +++ b/doorip-api/build.gradle @@ -14,6 +14,8 @@ dependencies { implementation project(path: ':doorip-domain') implementation project(path: ':doorip-external') implementation project(path: ':doorip-common') + implementation project(path: ':doorip-event-publisher') + implementation project(path: ':doorip-event-subscriber') } jar { From a37e6b2d407bee9522ce1c8edf851b74dad2d929 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:19:03 +0900 Subject: [PATCH 12/16] =?UTF-8?q?fix:=20=ED=9A=8C=EC=9B=90=EA=B0=80?= =?UTF-8?q?=EC=9E=85=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EB=B3=80=EA=B2=BD=20(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/doorip/message/EventMessage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doorip-common/src/main/java/org/doorip/message/EventMessage.java b/doorip-common/src/main/java/org/doorip/message/EventMessage.java index 7e83a66..577b3c0 100644 --- a/doorip-common/src/main/java/org/doorip/message/EventMessage.java +++ b/doorip-common/src/main/java/org/doorip/message/EventMessage.java @@ -7,7 +7,7 @@ @RequiredArgsConstructor(access = AccessLevel.PRIVATE) @Getter public enum EventMessage { - SIGN_UP_EVENT("doorip 서비스에 회원가입 이벤트가 발생했습니다. 🎉"); + SIGN_UP_EVENT("[🎉 doorip 회원가입 🎉]\n>> 닉네임: [%s]\n>> 현재 가입자 수: [%d명]"); private final String message; } From a16b93a1d8b351ca84d3f8a5bc82beda6de2b4f0 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:19:20 +0900 Subject: [PATCH 13/16] =?UTF-8?q?feat:=20=EA=B0=80=EC=9E=85=EC=9E=90=20?= =?UTF-8?q?=EC=88=98=20=EC=B9=B4=EC=9A=B4=ED=8C=85=20=EC=BF=BC=EB=A6=AC=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/doorip/user/repository/UserRepository.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doorip-domain/src/main/java/org/doorip/user/repository/UserRepository.java b/doorip-domain/src/main/java/org/doorip/user/repository/UserRepository.java index 42be847..d58de29 100644 --- a/doorip-domain/src/main/java/org/doorip/user/repository/UserRepository.java +++ b/doorip-domain/src/main/java/org/doorip/user/repository/UserRepository.java @@ -3,6 +3,7 @@ import org.doorip.user.domain.Platform; import org.doorip.user.domain.User; import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; import java.util.Optional; @@ -10,4 +11,7 @@ public interface UserRepository extends JpaRepository { Optional findUserByPlatformAndPlatformId(Platform platform, String platformId); boolean existsUserByPlatformAndPlatformId(Platform platform, String platformId); + + @Query("select count(*) from User u") + int countUser(); } From d734f31fca52d7988908fb3694a9a5d5bf6398aa Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:19:44 +0900 Subject: [PATCH 14/16] =?UTF-8?q?chore:=20root=20=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=A0=9C=EA=B1=B0=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doorip-api/src/main/java/org/doorip/DooripApplication.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doorip-api/src/main/java/org/doorip/DooripApplication.java b/doorip-api/src/main/java/org/doorip/DooripApplication.java index 6a59713..d81e403 100644 --- a/doorip-api/src/main/java/org/doorip/DooripApplication.java +++ b/doorip-api/src/main/java/org/doorip/DooripApplication.java @@ -3,9 +3,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication( - scanBasePackageClasses = {DomainRoot.class, CommonRoot.class, ExternalRoot.class} -) +@SpringBootApplication public class DooripApplication { public static void main(String[] args) { SpringApplication.run(DooripApplication.class, args); From 6018496a435cf6584f2f02cabf84c694ca6feeb2 Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:20:40 +0900 Subject: [PATCH 15/16] =?UTF-8?q?fix:=20=EB=94=94=EC=8A=A4=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EB=B0=94=EC=9D=B4=EB=8D=94=20=EB=A7=A4=EA=B0=9C=EB=B3=80?= =?UTF-8?q?=EC=88=98=20=EB=B3=80=EA=B2=BD=20(#153)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/doorip/openfeign/discord/DiscordMessageProvider.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordMessageProvider.java b/doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordMessageProvider.java index 6780e22..c365368 100644 --- a/doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordMessageProvider.java +++ b/doorip-external/src/main/java/org/doorip/openfeign/discord/DiscordMessageProvider.java @@ -4,7 +4,6 @@ import lombok.RequiredArgsConstructor; import org.doorip.exception.InvalidValueException; import org.doorip.message.ErrorMessage; -import org.doorip.message.EventMessage; import org.springframework.stereotype.Component; import static org.doorip.openfeign.discord.DiscordMessage.createDiscordMessage; @@ -14,8 +13,8 @@ public class DiscordMessageProvider { private final DiscordFeignClient discordFeignClient; - public void sendMessage(EventMessage eventMessage) { - DiscordMessage discordMessage = createDiscordMessage(eventMessage.getMessage()); + public void sendMessage(String message) { + DiscordMessage discordMessage = createDiscordMessage(message); sendMessageToDiscord(discordMessage); } From 9ec049629caadd6fbf7cd347a272e18bd4041c2b Mon Sep 17 00:00:00 2001 From: sunwoong Date: Fri, 19 Apr 2024 20:22:01 +0900 Subject: [PATCH 16/16] =?UTF-8?q?feat:=20=EA=B0=80=EC=9E=85=EC=9E=90=20?= =?UTF-8?q?=EC=88=98=20=EC=B9=B4=EC=9A=B4=ED=8C=85=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20&=20event=20publisher=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EB=B3=80=EA=B2=BD=20(#160)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/doorip/user/service/UserService.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/doorip-api/src/main/java/org/doorip/user/service/UserService.java b/doorip-api/src/main/java/org/doorip/user/service/UserService.java index 36e55ff..828d13e 100644 --- a/doorip-api/src/main/java/org/doorip/user/service/UserService.java +++ b/doorip-api/src/main/java/org/doorip/user/service/UserService.java @@ -4,6 +4,7 @@ import org.doorip.auth.jwt.JwtProvider; import org.doorip.auth.jwt.JwtValidator; import org.doorip.auth.jwt.Token; +import org.doorip.event.SignUpEvent; import org.doorip.exception.ConflictException; import org.doorip.exception.EntityNotFoundException; import org.doorip.exception.InvalidValueException; @@ -11,14 +12,10 @@ import org.doorip.message.ErrorMessage; import org.doorip.message.EventMessage; import org.doorip.openfeign.apple.AppleOAuthProvider; -import org.doorip.openfeign.discord.DiscordMessageProvider; import org.doorip.openfeign.kakao.KakaoOAuthProvider; +import org.doorip.publisher.EventPublisher; import org.doorip.user.domain.*; -import org.doorip.user.dto.request.ResultUpdateRequest; -import org.doorip.user.dto.request.UserReissueRequest; -import org.doorip.user.dto.request.UserSignInRequest; -import org.doorip.user.dto.request.UserSignUpRequest; -import org.doorip.user.dto.request.ProfileUpdateRequest; +import org.doorip.user.dto.request.*; import org.doorip.user.dto.response.ProfileGetResponse; import org.doorip.user.dto.response.UserSignInResponse; import org.doorip.user.dto.response.UserSignUpResponse; @@ -46,7 +43,7 @@ public class UserService { private final JwtValidator jwtValidator; private final AppleOAuthProvider appleOAuthProvider; private final KakaoOAuthProvider kakaoOAuthProvider; - private final DiscordMessageProvider discordMessageProvider; + private final EventPublisher eventPublisher; @Transactional(readOnly = true) public void splash(Long userId) { @@ -71,7 +68,8 @@ public UserSignUpResponse signUp(String token, UserSignUpRequest request) { User savedUser = saveUser(request, platformId, enumPlatform); Token issueToken = jwtProvider.issueToken(savedUser.getId()); updateRefreshToken(issueToken.refreshToken(), savedUser); - discordMessageProvider.sendMessage(EventMessage.SIGN_UP_EVENT); + int userCount = userRepository.countUser(); + eventPublisher.publishSignUpEvent(SignUpEvent.of(EventMessage.SIGN_UP_EVENT, savedUser.getName(), userCount)); return UserSignUpResponse.of(issueToken, savedUser.getId()); }