From 95acebf3dfcb508705a0ede3a8e29705d8413fe2 Mon Sep 17 00:00:00 2001 From: dongkyeomjang Date: Sat, 23 Nov 2024 17:05:15 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Feature/#104=20-=20refactor:=20Sche?= =?UTF-8?q?duledEventJob=EC=9D=84=20=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94?= =?UTF-8?q?=20=EB=B0=A9=EC=8B=9D=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ProcessCompletedEventService.java | 13 +++++++------ .../service/SignUpOwnerByDefaultService.java | 14 +++++++------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/daon/onjung/event/application/service/ProcessCompletedEventService.java b/src/main/java/com/daon/onjung/event/application/service/ProcessCompletedEventService.java index c3186f2..f2cc0dd 100644 --- a/src/main/java/com/daon/onjung/event/application/service/ProcessCompletedEventService.java +++ b/src/main/java/com/daon/onjung/event/application/service/ProcessCompletedEventService.java @@ -4,6 +4,7 @@ import com.daon.onjung.account.domain.User; import com.daon.onjung.account.domain.type.EBankName; import com.daon.onjung.account.repository.mysql.UserRepository; +import com.daon.onjung.core.domain.service.ScheduledEventJobService; import com.daon.onjung.core.dto.CreateVirtualAccountResponseDto; import com.daon.onjung.core.exception.error.ErrorCode; import com.daon.onjung.core.exception.type.CommonException; @@ -14,7 +15,6 @@ import com.daon.onjung.event.application.usecase.ProcessCompletedEventUseCase; import com.daon.onjung.event.domain.Event; import com.daon.onjung.event.domain.Ticket; -import com.daon.onjung.event.domain.event.EventScheduled; import com.daon.onjung.event.domain.service.EventService; import com.daon.onjung.event.domain.service.TicketService; import com.daon.onjung.event.repository.mysql.EventRepository; @@ -43,6 +43,7 @@ public class ProcessCompletedEventService implements ProcessCompletedEventUseCas private final EventService eventService; private final TicketService ticketService; + private final ScheduledEventJobService scheduledEventJobService; private final RestClientUtil restClientUtil; private final BankUtil bankUtil; @@ -90,11 +91,11 @@ public void execute(Long eventId) { // 새롭게 생성된 이벤트에 대한 종료일자에 맞춘 이벤트 발행. 발행한 이벤트는 이벤트 리스너에 의해 스케줄러에 등록됨 applicationEventPublisher.publishEvent( - EventScheduled.builder() - .eventId(newEvent.getId()) -// .scheduledTime(newEvent.getEndDate().plusDays(1).atStartOfDay()) - .scheduledTime(LocalDateTime.now().plusMinutes(1)) // 테스트용 1분 뒤 - .build() + scheduledEventJobService.createScheduledJob( + newEvent.getId(), +// newEvent.getEndDate().plusDays(1).atStartOfDay() + LocalDateTime.now().plusMinutes(1) // 테스트용 1분 뒤 + ) ); // 종료된 이벤트와 연결된 가상계좌에 모급된 금액을 조회 diff --git a/src/main/java/com/daon/onjung/security/application/service/SignUpOwnerByDefaultService.java b/src/main/java/com/daon/onjung/security/application/service/SignUpOwnerByDefaultService.java index e845979..fd923c2 100644 --- a/src/main/java/com/daon/onjung/security/application/service/SignUpOwnerByDefaultService.java +++ b/src/main/java/com/daon/onjung/security/application/service/SignUpOwnerByDefaultService.java @@ -7,12 +7,12 @@ import com.daon.onjung.account.domain.type.EBankName; import com.daon.onjung.account.repository.mysql.OwnerRepository; import com.daon.onjung.account.repository.mysql.StoreRepository; +import com.daon.onjung.core.domain.service.ScheduledEventJobService; import com.daon.onjung.core.dto.CreateVirtualAccountResponseDto; import com.daon.onjung.core.utility.BankUtil; import com.daon.onjung.core.utility.RestClientUtil; import com.daon.onjung.core.utility.S3Util; import com.daon.onjung.event.domain.Event; -import com.daon.onjung.event.domain.event.EventScheduled; import com.daon.onjung.event.domain.service.EventService; import com.daon.onjung.event.repository.mysql.EventRepository; import com.daon.onjung.security.application.dto.request.SignUpOwnerByDefaultRequestDto; @@ -29,7 +29,6 @@ import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.temporal.ChronoUnit; @Service @RequiredArgsConstructor @@ -42,6 +41,7 @@ public class SignUpOwnerByDefaultService implements SignUpOwnerByDefaultUseCase private final OwnerService ownerService; private final StoreService storeService; private final EventService eventService; + private final ScheduledEventJobService scheduledEventJobService; private final S3Util s3Util; private final BankUtil bankUtil; @@ -116,11 +116,11 @@ public void execute(MultipartFile logo, // 생성한 이벤트에 대해 이벤트 발행 applicationEventPublisher.publishEvent( - EventScheduled.builder() - .eventId(event.getId()) -// .scheduledTime(event.getEndDate().plusDays(1).atStartOfDay()) - .scheduledTime(LocalDateTime.now().plusMinutes(1)) // 테스트용 1분 뒤 - .build() + scheduledEventJobService.createScheduledJob( + event.getId(), +// event.getEndDate().plusDays(1).atStartOfDay() + LocalDateTime.now().plusMinutes(1) // 테스트용 1분 뒤 + ) ); }