-
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.
[TDC-140] 일단 유니크 키 제거
- Loading branch information
Showing
2 changed files
with
42 additions
and
22 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
33 changes: 33 additions & 0 deletions
33
...ollar-core/threedollar-domain/src/main/java/com/threedollar/domain/coupon/CouponTime.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,33 @@ | ||
package com.threedollar.domain.coupon; | ||
|
||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Embeddable; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Embeddable | ||
@NoArgsConstructor | ||
@Getter | ||
public class CouponTime { | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime startTime; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime endTime; | ||
|
||
public CouponTime(LocalDateTime startTime, LocalDateTime endTime) { | ||
validateCouponTime(startTime, endTime); | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
} | ||
|
||
private void validateCouponTime(LocalDateTime startTime, LocalDateTime endTime) { | ||
if (startTime.isAfter(endTime)) { | ||
throw new IllegalArgumentException("startTime is after endTime"); | ||
} | ||
} | ||
} |