-
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.
- Loading branch information
Showing
4 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
threedollar-core/threedollar-domain/src/main/java/com/threedollar/domain/coupon/Coupon.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,93 @@ | ||
package com.threedollar.domain.coupon; | ||
|
||
import com.threedollar.domain.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.Table; | ||
import jakarta.persistence.UniqueConstraint; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.AccessLevel; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.checkerframework.checker.units.qual.C; | ||
|
||
@Entity | ||
@Getter | ||
@NoArgsConstructor | ||
@Table(uniqueConstraints = { | ||
@UniqueConstraint( | ||
name = "uni_coupon_1", | ||
columnNames = {} | ||
) | ||
}) | ||
public class Coupon extends BaseEntity { | ||
|
||
@Column(nullable = false, length = 100) | ||
private String workspaceId; | ||
|
||
@Column(nullable = false) | ||
private String targetId; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private CouponType couponType; | ||
|
||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private CouponStatus status; | ||
|
||
@Column(nullable = false) | ||
@Enumerated(EnumType.STRING) | ||
private CouponTag couponTag; | ||
|
||
@Column(nullable = false) | ||
private long count; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime startTime; | ||
|
||
@Column(nullable = false) | ||
private LocalDateTime endTime; | ||
|
||
@Column(nullable = false) | ||
private String accountId; | ||
|
||
@Builder(access = AccessLevel.PRIVATE) | ||
public Coupon(String workspaceId, String targetId, String name, CouponType couponType, | ||
CouponTag couponTag, CouponStatus status, long count, LocalDateTime startTime, LocalDateTime endTime, | ||
String accountId) { | ||
this.workspaceId = workspaceId; | ||
this.targetId = targetId; | ||
this.name = name; | ||
this.couponTag = couponTag; | ||
this.couponType = couponType; | ||
this.status = status; | ||
this.count = count; | ||
this.startTime = startTime; | ||
this.endTime = endTime; | ||
this.accountId = accountId; | ||
} | ||
|
||
public static Coupon newInstance(String workspaceId, String targetId, String name, | ||
CouponType couponType, CouponTag couponTag, long count, LocalDateTime startTime, LocalDateTime endTime) { | ||
return Coupon.builder() | ||
.couponType(couponType) | ||
.workspaceId(workspaceId) | ||
.targetId(targetId) | ||
.name(name) | ||
.couponTag(couponTag) | ||
.count(count) | ||
.status(CouponStatus.ACTIVE) | ||
.startTime(startTime) | ||
.endTime(endTime) | ||
.build(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...lar-core/threedollar-domain/src/main/java/com/threedollar/domain/coupon/CouponStatus.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,17 @@ | ||
package com.threedollar.domain.coupon; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum CouponStatus { | ||
ACTIVE("활성화") | ||
,DELETED("삭제됨") | ||
; | ||
|
||
private final String description; | ||
|
||
CouponStatus(String description) { | ||
this.description = description; | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...dollar-core/threedollar-domain/src/main/java/com/threedollar/domain/coupon/CouponTag.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,16 @@ | ||
package com.threedollar.domain.coupon; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum CouponTag { | ||
|
||
BOSS_EVENT("사장님 이벤트") | ||
; | ||
|
||
private final String description; | ||
|
||
CouponTag(String description) { | ||
this.description = description; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
...ollar-core/threedollar-domain/src/main/java/com/threedollar/domain/coupon/CouponType.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,17 @@ | ||
package com.threedollar.domain.coupon; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public enum CouponType { | ||
LIMITED("수량제한"), | ||
UNLIMITED("무제한"), | ||
; | ||
private final String description; | ||
|
||
CouponType(String description) { | ||
this.description = description; | ||
} | ||
|
||
|
||
} |