Skip to content

Commit

Permalink
[#221] refactor(HomePromotionDetail): 정적 팩토리 메서드 내에서 초기화해서 return 하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hoonyworld committed Oct 1, 2024
1 parent 91327b2 commit 0539206
Showing 1 changed file with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.beat.domain.performance.application.dto.home;

public record HomePromotionDetail(
Long promotionId,
String promotionPhoto,
Long performanceId,
String redirectUrl,
boolean isExternal
) {
public static HomePromotionDetail of(Long promotionId, String promotionPhoto, Long performanceId, String redirectUrl, boolean isExternal) {
return new HomePromotionDetail(promotionId, promotionPhoto, performanceId, redirectUrl, isExternal);
}
import com.beat.domain.promotion.domain.CarouselNumber;
import com.beat.domain.promotion.domain.Promotion;

public record HomePromotionDetail(Long promotionId, String promotionPhoto, Long performanceId, String redirectUrl,
boolean isExternal, CarouselNumber carouselNumber) {

public static HomePromotionDetail from(Promotion promotion) {
Long performanceId = null;

if (promotion.getPerformance() != null) {
performanceId = promotion.getPerformance().getId();
}

return new HomePromotionDetail(promotion.getId(), promotion.getPromotionPhoto(), performanceId,
promotion.getRedirectUrl(), promotion.isExternal(), promotion.getCarouselNumber());
}
}

0 comments on commit 0539206

Please sign in to comment.