Skip to content

Commit

Permalink
[TDC-139] feat: 쿠폰 도메인 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
yerimkoko committed Jan 6, 2025
1 parent 60ff6da commit 6a97d22
Show file tree
Hide file tree
Showing 4 changed files with 143 additions and 0 deletions.
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();
}
}
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;
}

}
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;
}
}
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;
}


}

0 comments on commit 6a97d22

Please sign in to comment.