Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import lombok.Getter;

@Getter
Expand All @@ -13,8 +12,7 @@ public class PriceAlertRequest {
@Schema(description = "상품 ID", example = "1")
private Long productId;

@NotNull(message = "목표 가격은 필수입니다.")
@Positive(message = "목표 가격은 양수여야 합니다.")
@Schema(description = "목표 가격 (사용자가 선택한 할인가)", example = "47500")
private Integer targetPrice;
@NotNull(message = "할인율은 필수입니다.")
@Schema(description = "할인율 (10, 20, 30, 40 중 선택)", example = "20", allowableValues = {"10", "20", "30", "40"})
private Integer discountRate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ public PriceAlert createOrUpdatePriceAlert(Long userId, PriceAlertRequest reques
priceAlertRepository.findByUserIdAndProductIdAndIsActiveTrue(userId, request.getProductId())
.ifPresent(PriceAlert::deactivate);

// 할인율로 목표 가격 계산
int targetPrice = product.getPrice() * (100 - request.getDiscountRate()) / 100;

// 새 건 생성
PriceAlert priceAlert = PriceAlert.builder()
.targetPrice(request.getTargetPrice())
.targetPrice(targetPrice)
.isActive(true)
.user(user)
.product(product)
Expand Down