-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] #172 - promotion 필드 추가 및 지난 공연 캐러샐 자동 삭제 구현, response에 dueDate…
… 추가 (#175) * [#172] feat(BeatApplication): cron 관련 annotation 추가 * [#172] feat(Promotion): promotion entity에 추가로 필요한 필드 추가 * [#172] feat(PromotionService): 지나간 공연에 해당하는 promotion 캐러셀 삭제하는 로직 구현 * [#172] feat(PerformanceDetailResponse): 공연 상세 정보 조회 response에 minDueDate 추가 * [#172] feat(PerformanceDetailResponse): 공연 상세 정보 조회 response에 schedule별 dueDate 추가 * [#172] feat(BookingPerformanceDetailSchedule): 예매하기에 필요한 공연 상세 정보 조회 response에 schedule별 dueDate 추가 * [#172] feat(MakerPerformanceDetail): 등록한 공연 조회 response에 MinDueDate 추가 * [#172] feat(PerformanceService): response에 추가한 필드 반영 및 등록한 공연 조회 정렬 로직 구현 * [#172] refactor(PromotionService): checkAndDeleteInvalidPromotions 성능 및 확장성 고려한 refactor
- Loading branch information
1 parent
dae27a6
commit fe0bb64
Showing
8 changed files
with
141 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/beat/domain/promotion/application/PromotionService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.beat.domain.promotion.application; | ||
|
||
import com.beat.domain.performance.domain.Performance; | ||
import com.beat.domain.promotion.dao.PromotionRepository; | ||
import com.beat.domain.promotion.domain.Promotion; | ||
import com.beat.domain.schedule.application.ScheduleService; | ||
import com.beat.domain.schedule.dao.ScheduleRepository; | ||
import com.beat.domain.schedule.domain.Schedule; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import java.util.List; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class PromotionService { | ||
|
||
private final PromotionRepository promotionRepository; | ||
private final ScheduleRepository scheduleRepository; | ||
private final ScheduleService scheduleService; | ||
|
||
@Scheduled(cron = "1 0 0 * * ?") | ||
@Transactional | ||
public void checkAndDeleteInvalidPromotions() { | ||
List<Promotion> promotions = promotionRepository.findAll(); | ||
|
||
for (Promotion promotion : promotions) { | ||
Performance performance = promotion.getPerformance(); | ||
|
||
if (performance == null) { | ||
return; | ||
} | ||
|
||
List<Schedule> schedules = scheduleRepository.findByPerformanceId(performance.getId()); | ||
int minDueDate = scheduleService.getMinDueDate(schedules); | ||
|
||
if (minDueDate < 0) { | ||
promotionRepository.delete(promotion); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters