From 70953b8a15dd13ed7d6ac2ba0a663771c9d589ea Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:27:01 +0900 Subject: [PATCH 1/9] rename: notification writer -> daily_spending_notify_writer --- .../{NotificationWriter.java => DailySpendingNotifyWriter.java} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/{NotificationWriter.java => DailySpendingNotifyWriter.java} (96%) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/NotificationWriter.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java similarity index 96% rename from pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/NotificationWriter.java rename to pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java index e7baad6f7..631a31fee 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/NotificationWriter.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java @@ -23,7 +23,7 @@ @Slf4j @Component @RequiredArgsConstructor -public class NotificationWriter implements ItemWriter { +public class DailySpendingNotifyWriter implements ItemWriter { private final NotificationRepository notificationRepository; private final ApplicationEventPublisher publisher; From f31e64aae8091a374dc3fc799a60e4363ddbe09c Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:32:25 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20announcement=20enum=20class=20not=5F?= =?UTF-8?q?announce=20=ED=83=80=EC=9E=85=20=ED=95=84=ED=84=B0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...gNotification.java => AnnounceNotificationDto.java} | 10 ++-------- .../domain/domains/notification/type/Announcement.java | 4 ++++ 2 files changed, 6 insertions(+), 8 deletions(-) rename pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/{DailySpendingNotification.java => AnnounceNotificationDto.java} (80%) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/DailySpendingNotification.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java similarity index 80% rename from pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/DailySpendingNotification.java rename to pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java index aebce3313..8c92ab1ad 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/DailySpendingNotification.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java @@ -22,20 +22,14 @@ public record DailySpendingNotification( Objects.requireNonNull(deviceTokens, "deviceTokens must not be null"); } - /** - * {@link DeviceTokenOwner}를 DailySpendingNotification DTO로 변환하는 정적 팩토리 메서드 - *

- * DeviceToken은 List로 변환되어 멤버 변수로 관리하게 된다. - */ - public static DailySpendingNotification from(DeviceTokenOwner owner) { - Announcement announcement = Announcement.DAILY_SPENDING; + public static DailySpendingNotification from(DeviceTokenOwner owner, Announcement announcement) { Set deviceTokens = new HashSet<>(); deviceTokens.add(owner.deviceToken()); return DailySpendingNotification.builder() .userId(owner.userId()) .title(announcement.createFormattedTitle(owner.name())) - .content(announcement.getContent()) + .content(announcement.createFormattedContent(owner.name())) .deviceTokens(deviceTokens) .build(); } diff --git a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java index b538cf531..69339aa73 100644 --- a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java +++ b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java @@ -62,5 +62,9 @@ private void validateName(String name) { if (!StringUtils.hasText(name)) { throw new IllegalArgumentException("name must not be empty"); } + + if (this == NOT_ANNOUNCE) { + throw new IllegalArgumentException("NOT_ANNOUNCE type is not allowed"); + } } } From 8e63ef7df3ae56e2ff32d4f8df32cb1404046607 Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:34:14 +0900 Subject: [PATCH 3/9] =?UTF-8?q?fix:=20daily=5Fnotication=20dto=20=EB=B2=94?= =?UTF-8?q?=EC=9A=A9=EC=84=B1=20=ED=99=95=EC=9E=A5=ED=95=98=EC=97=AC=20ann?= =?UTF-8?q?ounce=5Fnotification=5Fdto=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/common/dto/AnnounceNotificationDto.java | 8 ++++---- .../pennyway/batch/writer/DailySpendingNotifyWriter.java | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java index 8c92ab1ad..8ef17f268 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java @@ -9,24 +9,24 @@ import java.util.Set; @Builder -public record DailySpendingNotification( +public record AnnounceNotificationDto( Long userId, String title, String content, Set deviceTokens ) { - public DailySpendingNotification { + public AnnounceNotificationDto { Objects.requireNonNull(userId, "userId must not be null"); Objects.requireNonNull(title, "title must not be null"); Objects.requireNonNull(content, "content must not be null"); Objects.requireNonNull(deviceTokens, "deviceTokens must not be null"); } - public static DailySpendingNotification from(DeviceTokenOwner owner, Announcement announcement) { + public static AnnounceNotificationDto from(DeviceTokenOwner owner, Announcement announcement) { Set deviceTokens = new HashSet<>(); deviceTokens.add(owner.deviceToken()); - return DailySpendingNotification.builder() + return AnnounceNotificationDto.builder() .userId(owner.userId()) .title(announcement.createFormattedTitle(owner.name())) .content(announcement.createFormattedContent(owner.name())) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java index 631a31fee..3c2853cb0 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/DailySpendingNotifyWriter.java @@ -1,6 +1,6 @@ package kr.co.pennyway.batch.writer; -import kr.co.pennyway.batch.common.dto.DailySpendingNotification; +import kr.co.pennyway.batch.common.dto.AnnounceNotificationDto; import kr.co.pennyway.batch.common.dto.DeviceTokenOwner; import kr.co.pennyway.domain.domains.notification.repository.NotificationRepository; import kr.co.pennyway.domain.domains.notification.type.Announcement; @@ -33,17 +33,17 @@ public class DailySpendingNotifyWriter implements ItemWriter { public void write(@NonNull Chunk owners) throws Exception { log.info("Writer 실행: {}", owners.size()); - Map notificationMap = new HashMap<>(); + Map notificationMap = new HashMap<>(); for (DeviceTokenOwner owner : owners) { - notificationMap.computeIfAbsent(owner.userId(), k -> DailySpendingNotification.from(owner)).addDeviceToken(owner.deviceToken()); + notificationMap.computeIfAbsent(owner.userId(), k -> AnnounceNotificationDto.from(owner, Announcement.DAILY_SPENDING)).addDeviceToken(owner.deviceToken()); } List userIds = new ArrayList<>(notificationMap.keySet()); notificationRepository.saveDailySpendingAnnounceInBulk(userIds, Announcement.DAILY_SPENDING); - for (DailySpendingNotification notification : notificationMap.values()) { + for (AnnounceNotificationDto notification : notificationMap.values()) { publisher.publishEvent(NotificationEvent.of(notification.title(), notification.content(), notification.deviceTokensForList(), "")); } } From adbf36585c3cacf18f4f9888d67d96f6582d5a6f Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:36:58 +0900 Subject: [PATCH 4/9] =?UTF-8?q?feat:=20=EB=A7=A4=EC=9B=94=20=EB=AA=A9?= =?UTF-8?q?=ED=91=9C=20=EA=B8=88=EC=95=A1=20=EC=84=A4=EC=A0=95=20=EA=B3=B5?= =?UTF-8?q?=EC=A7=80=20writer=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MonthlyTotalAmountNotifyWriter.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/MonthlyTotalAmountNotifyWriter.java diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/MonthlyTotalAmountNotifyWriter.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/MonthlyTotalAmountNotifyWriter.java new file mode 100644 index 000000000..ac769945b --- /dev/null +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/writer/MonthlyTotalAmountNotifyWriter.java @@ -0,0 +1,50 @@ +package kr.co.pennyway.batch.writer; + +import kr.co.pennyway.batch.common.dto.AnnounceNotificationDto; +import kr.co.pennyway.batch.common.dto.DeviceTokenOwner; +import kr.co.pennyway.domain.domains.notification.repository.NotificationRepository; +import kr.co.pennyway.domain.domains.notification.type.Announcement; +import kr.co.pennyway.infra.common.event.NotificationEvent; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.batch.core.configuration.annotation.StepScope; +import org.springframework.batch.item.Chunk; +import org.springframework.batch.item.ItemWriter; +import org.springframework.context.ApplicationEventPublisher; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@Component +@RequiredArgsConstructor +public class MonthlyTotalAmountNotifyWriter implements ItemWriter { + private final NotificationRepository notificationRepository; + private final ApplicationEventPublisher publisher; + + @Override + @StepScope + @Transactional + public void write(@NonNull Chunk owners) throws Exception { + log.info("Writer 실행: {}", owners.size()); + + Map notificationMap = new HashMap<>(); + + for (DeviceTokenOwner owner : owners) { + notificationMap.computeIfAbsent(owner.userId(), k -> AnnounceNotificationDto.from(owner, Announcement.MONTHLY_TARGET_AMOUNT)).addDeviceToken(owner.deviceToken()); + } + + List userIds = new ArrayList<>(notificationMap.keySet()); + + notificationRepository.saveDailySpendingAnnounceInBulk(userIds, Announcement.MONTHLY_TARGET_AMOUNT); + + for (AnnounceNotificationDto notification : notificationMap.values()) { + publisher.publishEvent(NotificationEvent.of(notification.title(), notification.content(), notification.deviceTokensForList(), "")); + } + } +} From 917764468f98e0903837ed549894bbb0c5d360b9 Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:37:58 +0900 Subject: [PATCH 5/9] feat: monthly_target_amount_notify_config job $ step impl --- .../batch/job/DailySpendingNotifyConfig.java | 4 +- .../job/MonthlyTargetAmountNotifyConfig.java | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 pennyway-batch/src/main/java/kr/co/pennyway/batch/job/MonthlyTargetAmountNotifyConfig.java diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/DailySpendingNotifyConfig.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/DailySpendingNotifyConfig.java index 8130ace3b..10a7f99f1 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/DailySpendingNotifyConfig.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/DailySpendingNotifyConfig.java @@ -2,7 +2,7 @@ import kr.co.pennyway.batch.common.dto.DeviceTokenOwner; import kr.co.pennyway.batch.reader.ActiveDeviceTokenReader; -import kr.co.pennyway.batch.writer.NotificationWriter; +import kr.co.pennyway.batch.writer.DailySpendingNotifyWriter; import lombok.RequiredArgsConstructor; import org.springframework.batch.core.Job; import org.springframework.batch.core.Step; @@ -19,7 +19,7 @@ public class DailySpendingNotifyConfig { private final JobRepository jobRepository; private final ActiveDeviceTokenReader reader; - private final NotificationWriter writer; + private final DailySpendingNotifyWriter writer; @Bean public Job dailyNotificationJob(PlatformTransactionManager transactionManager) { diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/MonthlyTargetAmountNotifyConfig.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/MonthlyTargetAmountNotifyConfig.java new file mode 100644 index 000000000..6708bd346 --- /dev/null +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/job/MonthlyTargetAmountNotifyConfig.java @@ -0,0 +1,45 @@ +package kr.co.pennyway.batch.job; + +import kr.co.pennyway.batch.common.dto.DeviceTokenOwner; +import kr.co.pennyway.batch.reader.ActiveDeviceTokenReader; +import kr.co.pennyway.batch.writer.MonthlyTotalAmountNotifyWriter; +import lombok.RequiredArgsConstructor; +import org.springframework.batch.core.Job; +import org.springframework.batch.core.Step; +import org.springframework.batch.core.configuration.annotation.JobScope; +import org.springframework.batch.core.job.builder.JobBuilder; +import org.springframework.batch.core.repository.JobRepository; +import org.springframework.batch.core.step.builder.StepBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.transaction.PlatformTransactionManager; + +@Configuration +@RequiredArgsConstructor +public class MonthlyTargetAmountNotifyConfig { + private final JobRepository jobRepository; + private final ActiveDeviceTokenReader reader; + private final MonthlyTotalAmountNotifyWriter writer; + + @Bean + public Job monthlyNotificationJob(PlatformTransactionManager transactionManager) { + return new JobBuilder("monthlyNotificationJob", jobRepository) + .start(monthlyNotificationStep(transactionManager)) + .on("FAILED") + .stopAndRestart(monthlyNotificationStep(transactionManager)) + .on("*") + .end() + .end() + .build(); + } + + @Bean + @JobScope + public Step monthlyNotificationStep(PlatformTransactionManager transactionManager) { + return new StepBuilder("sendMonthlyNotifyStep", jobRepository) + .chunk(1000, transactionManager) + .reader(reader.querydslNoOffsetPagingItemReader()) + .writer(writer) + .build(); + } +} From 75627b13210dd164b802ea5257b8deb76bf0b922 Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:41:26 +0900 Subject: [PATCH 6/9] =?UTF-8?q?feat:=20=EB=A7=A4=EC=9B=94=20=EC=A0=95?= =?UTF-8?q?=EA=B8=B0=20=EB=AA=A9=ED=91=9C=20=EA=B8=88=EC=95=A1=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=95=8C=EB=A6=BC=20=EC=8A=A4=EC=BC=80=EC=A4=84=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/scheduler/SpendingNotifyScheduler.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java index 8d36bd04b..a07982f7e 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/scheduler/SpendingNotifyScheduler.java @@ -19,6 +19,7 @@ public class SpendingNotifyScheduler { private final JobLauncher jobLauncher; private final Job dailyNotificationJob; + private final Job monthlyNotificationJob; @Scheduled(cron = "0 0 20 * * ?") public void runDailyNotificationJob() { @@ -33,4 +34,18 @@ public void runDailyNotificationJob() { log.error("Failed to run dailyNotificationJob", e); } } + + @Scheduled(cron = "0 0 10 1 * ?") + public void runMonthlyNotificationJob() { + JobParameters jobParameters = new JobParametersBuilder() + .addLong("time", System.currentTimeMillis()) + .toJobParameters(); + + try { + jobLauncher.run(monthlyNotificationJob, jobParameters); + } catch (JobExecutionAlreadyRunningException | JobRestartException + | JobInstanceAlreadyCompleteException | JobParametersInvalidException e) { + log.error("Failed to run monthlyNotificationJob", e); + } + } } From d4a16838a74e4c7b7c86cb47fce972b03617478a Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 00:58:42 +0900 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20=EB=AA=A9=ED=91=9C=20=EA=B8=88?= =?UTF-8?q?=EC=95=A1=20=EC=95=8C=EB=A6=BC=20=EB=A9=94=EC=8B=9C=EC=A7=80=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=EC=8B=9C,=20title=20=ED=95=B4=EB=8B=B9=20?= =?UTF-8?q?=EC=9B=94=20=EC=82=BD=EC=9E=85=EB=90=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/domain/Notification.java | 22 ++++++++++++++----- .../notification/type/Announcement.java | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/domain/Notification.java b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/domain/Notification.java index 01de09e64..49034994b 100644 --- a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/domain/Notification.java +++ b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/domain/Notification.java @@ -72,10 +72,19 @@ public String toString() { * @apiNote 이 메서드는 {@link NoticeType#ANNOUNCEMENT} 타입에 대해서만 동작한다. 다른 타입의 알림을 포맷팅해야 하는 경우 해당 메서드를 확장해야 한다. */ public String createFormattedTitle() { - if (type.equals(NoticeType.ANNOUNCEMENT)) { - return announcement.createFormattedTitle(receiverName); + if (!type.equals(NoticeType.ANNOUNCEMENT)) { + return ""; // TODO: 알림 종류가 신규로 추가될 때, 해당 로직을 구현해야 함. } - return ""; // TODO: 알림 종류가 신규로 추가될 때, 해당 로직을 구현해야 함. + + return formatAnnouncementTitle(); + } + + private String formatAnnouncementTitle() { + if (announcement.equals(Announcement.MONTHLY_TARGET_AMOUNT)) { + return announcement.createFormattedTitle(String.valueOf(getCreatedAt().getMonthValue())); + } + + return announcement.createFormattedTitle(receiverName); } /** @@ -86,10 +95,11 @@ public String createFormattedTitle() { * @apiNote 이 메서드는 {@link NoticeType#ANNOUNCEMENT} 타입에 대해서만 동작한다. 다른 타입의 알림을 포맷팅해야 하는 경우 해당 메서드를 확장해야 한다. */ public String createFormattedContent() { - if (type.equals(NoticeType.ANNOUNCEMENT)) { - return announcement.createFormattedContent(receiverName); + if (!type.equals(NoticeType.ANNOUNCEMENT)) { + return ""; // TODO: 알림 종류가 신규로 추가될 때, 해당 로직을 구현해야 함. } - return ""; // TODO: 알림 종류가 신규로 추가될 때, 해당 로직을 구현해야 함. + + return announcement.createFormattedContent(receiverName); } public static class Builder { diff --git a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java index 69339aa73..7cd501082 100644 --- a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java +++ b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java @@ -10,7 +10,7 @@ public enum Announcement implements LegacyCommonType { // 정기 지출 알림 DAILY_SPENDING("1", "%s님, 3분 카레보다 빨리 끝나요!", "많은 친구들이 소비 기록에 참여하고 있어요👀"), - MONTHLY_TARGET_AMOUNT("2", "6월의 첫 시작! 두구두구..🥁", "%s님의 이번 달 목표 소비 금액은?"); + MONTHLY_TARGET_AMOUNT("2", "%월의 첫 시작! 두구두구..🥁", "%s님의 이번 달 목표 소비 금액은?"); private final String code; private final String title; From 88083eb901dd03e6176f524bbf94e91da6b9080c Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:08:31 +0900 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20monthly=5Ftarget=5Famount=20title=20?= =?UTF-8?q?%s=EB=88=84=EB=9D=BD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pennyway/domain/domains/notification/type/Announcement.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java index 7cd501082..30fd87df9 100644 --- a/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java +++ b/pennyway-domain/src/main/java/kr/co/pennyway/domain/domains/notification/type/Announcement.java @@ -10,7 +10,7 @@ public enum Announcement implements LegacyCommonType { // 정기 지출 알림 DAILY_SPENDING("1", "%s님, 3분 카레보다 빨리 끝나요!", "많은 친구들이 소비 기록에 참여하고 있어요👀"), - MONTHLY_TARGET_AMOUNT("2", "%월의 첫 시작! 두구두구..🥁", "%s님의 이번 달 목표 소비 금액은?"); + MONTHLY_TARGET_AMOUNT("2", "%s월의 첫 시작! 두구두구..🥁", "%s님의 이번 달 목표 소비 금액은?"); private final String code; private final String title; From 19f348911b73f34193e0b878f130dcaddbffea47 Mon Sep 17 00:00:00 2001 From: JaeSeo Yang <96044622+psychology50@users.noreply.github.com> Date: Fri, 26 Jul 2024 01:09:28 +0900 Subject: [PATCH 9/9] =?UTF-8?q?fix:=20announce=20notification=20dto=20?= =?UTF-8?q?=EB=82=B4=EB=B6=80=EC=97=90=EC=84=9C=20=EC=9B=94=EB=B3=84=20?= =?UTF-8?q?=EB=AA=A9=ED=91=9C=20=EA=B8=88=EC=95=A1=20title=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C,=20=EB=B6=84=EA=B8=B0=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../batch/common/dto/AnnounceNotificationDto.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java b/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java index 8ef17f268..f9b591da3 100644 --- a/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java +++ b/pennyway-batch/src/main/java/kr/co/pennyway/batch/common/dto/AnnounceNotificationDto.java @@ -3,6 +3,7 @@ import kr.co.pennyway.domain.domains.notification.type.Announcement; import lombok.Builder; +import java.time.LocalDateTime; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -28,12 +29,20 @@ public static AnnounceNotificationDto from(DeviceTokenOwner owner, Announcement return AnnounceNotificationDto.builder() .userId(owner.userId()) - .title(announcement.createFormattedTitle(owner.name())) + .title(createFormattedTitle(owner, announcement)) .content(announcement.createFormattedContent(owner.name())) .deviceTokens(deviceTokens) .build(); } + private static String createFormattedTitle(DeviceTokenOwner owner, Announcement announcement) { + if (announcement.equals(Announcement.MONTHLY_TARGET_AMOUNT)) { + return announcement.createFormattedTitle(String.valueOf(LocalDateTime.now().getMonthValue())); + } + + return announcement.createFormattedTitle(owner.name()); + } + public void addDeviceToken(String deviceToken) { deviceTokens.add(deviceToken); }