Skip to content

Commit

Permalink
[#219] refactor(PromotionService): 캐러셀넘버로 Promotion 객체를 찾는 메서드 구현 및 캐…
Browse files Browse the repository at this point in the history
…러셀 넘버로 삭제 시 리스트 형태로 주도록 변경
  • Loading branch information
hoonyworld committed Sep 30, 2024
1 parent dc046e6 commit 6fb9dc3
Showing 1 changed file with 13 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.List;

@Service
@Transactional
@RequiredArgsConstructor
public class PromotionService implements PromotionUseCase {

Expand All @@ -36,41 +37,34 @@ public List<Promotion> findAllPromotions() {
}

@Override
@Transactional
public Promotion createPromotion(String newImageUrl, Performance performance, String redirectUrl,
boolean isExternal, CarouselNumber carouselNumber) {
Promotion newPromotion = Promotion.create(
newImageUrl,
performance,
redirectUrl,
isExternal,
carouselNumber
);
Promotion newPromotion = Promotion.create(newImageUrl, performance, redirectUrl, isExternal, carouselNumber);
return promotionRepository.save(newPromotion);
}

@Override
@Transactional
public Promotion modifyPromotion(Promotion promotion, Performance performance, PromotionModifyRequest request) {
promotion.updatePromotionDetails(
request.carouselNumber(),
request.newImageUrl(),
request.isExternal(),
request.redirectUrl(),
performance
);
promotion.updatePromotionDetails(request.carouselNumber(), request.newImageUrl(), request.isExternal(),
request.redirectUrl(), performance);
return promotionRepository.save(promotion);
}

@Override
@Transactional
public void deleteByCarouselNumber(CarouselNumber carouselNumber) {
promotionRepository.deleteByCarouselNumber(carouselNumber);
public void deleteByCarouselNumber(List<CarouselNumber> carouselNumber) {
promotionRepository.deleteByCarouselNumbers(carouselNumber);
}

@Override
@Transactional(readOnly = true)
public List<CarouselNumber> findAllCarouselNumbers() {
return promotionRepository.findAllCarouselNumbers();
}

@Override
@Transactional(readOnly = true)
public Promotion findPromotionByCarouselNumber(CarouselNumber carouselNumber) {
return promotionRepository.findByCarouselNumber(carouselNumber)
.orElseThrow(() -> new NotFoundException(PromotionErrorCode.PROMOTION_NOT_FOUND));
}
}

0 comments on commit 6fb9dc3

Please sign in to comment.