Skip to content

Commit

Permalink
✨ Feature/#104 - refactor: ScheduledEventJob을 사용하는 방식으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
dongkyeomjang committed Nov 23, 2024
1 parent faa2b94 commit 95acebf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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분 뒤
)
);

// 종료된 이벤트와 연결된 가상계좌에 모급된 금액을 조회
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,7 +29,6 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

@Service
@RequiredArgsConstructor
Expand All @@ -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;
Expand Down Expand Up @@ -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분 뒤
)
);

}
Expand Down

0 comments on commit 95acebf

Please sign in to comment.