forked from Eunnee/popool
-
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
7 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
Payment-Service/src/main/java/kr/co/paymentservice/domain/entity/CouponEntity.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 kr.co.paymentservice.domain.entity; | ||
|
||
import lombok.Getter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Getter | ||
@DiscriminatorValue("C") | ||
@Entity | ||
public class CouponEntity extends ItemMstEntity { | ||
|
||
@Column(nullable = false) | ||
private int amount; | ||
} |
25 changes: 25 additions & 0 deletions
25
Payment-Service/src/main/java/kr/co/paymentservice/domain/entity/ItemMstEntity.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,25 @@ | ||
package kr.co.paymentservice.domain.entity; | ||
|
||
import kr.co.paymentservice.domain.shared.BaseEntity; | ||
import lombok.Getter; | ||
|
||
import javax.persistence.*; | ||
|
||
@Getter | ||
@Entity | ||
@Table(name = "tbl_item_mst") | ||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE) | ||
@DiscriminatorColumn(name = "dtype") | ||
public abstract class ItemMstEntity extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "item_id") | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private int price; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
} |
17 changes: 17 additions & 0 deletions
17
Payment-Service/src/main/java/kr/co/paymentservice/domain/entity/PeriodCouponEntity.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 kr.co.paymentservice.domain.entity; | ||
|
||
import kr.co.paymentservice.domain.shared.enums.CouponPeriod; | ||
import lombok.Getter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
|
||
@Getter | ||
@DiscriminatorValue("P") | ||
@Entity | ||
public class PeriodCouponEntity extends ItemMstEntity { | ||
|
||
@Column(nullable = false) | ||
private CouponPeriod period; | ||
} |
17 changes: 17 additions & 0 deletions
17
Payment-Service/src/main/java/kr/co/paymentservice/domain/entity/SubscribeEntity.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 kr.co.paymentservice.domain.entity; | ||
|
||
import lombok.Getter; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.DiscriminatorValue; | ||
import javax.persistence.Entity; | ||
import java.time.LocalDate; | ||
|
||
@Getter | ||
@DiscriminatorValue("S") | ||
@Entity | ||
public class SubscribeEntity extends ItemMstEntity{ | ||
|
||
@Column(nullable = false) | ||
private LocalDate payDatePerMonth; | ||
} |
26 changes: 26 additions & 0 deletions
26
Payment-Service/src/main/java/kr/co/paymentservice/domain/shared/enums/CouponPeriod.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,26 @@ | ||
package kr.co.paymentservice.domain.shared.enums; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.Arrays; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum CouponPeriod { | ||
|
||
ONE_MONTH(1, "1개월"), | ||
THREE_MONTH(3, "3개월"), | ||
SIX_MONTH(6, "6개월"), | ||
ONE_YEAR(12, "1년"); | ||
|
||
private int period; | ||
private String period_str; | ||
|
||
public static CouponPeriod of(String period_str) { | ||
|
||
return Arrays.stream(CouponPeriod.values()) | ||
.filter(c -> c.toString().equalsIgnoreCase(period_str)) | ||
.findAny().orElseThrow(() -> new RuntimeException("해당 기간의 쿠폰 항목을 찾을 수 없습니다.")); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
Payment-Service/src/main/java/kr/co/paymentservice/repository/ItemMstRepository.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,10 @@ | ||
package kr.co.paymentservice.repository; | ||
|
||
import kr.co.paymentservice.domain.entity.ItemMstEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface ItemMstRepository extends JpaRepository<ItemMstEntity, Long> { | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
Payment-Service/src/test/java/kr/co/paymentservice/repository/ItemMstRepositoryTest.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,23 @@ | ||
package kr.co.paymentservice.repository; | ||
|
||
import kr.co.paymentservice.domain.entity.CouponEntity; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@DataJpaTest | ||
class ItemMstRepositoryTest { | ||
|
||
@Autowired | ||
ItemMstRepository itemMstRepository; | ||
|
||
@Test | ||
void save() { | ||
CouponEntity coupon = new CouponEntity(); | ||
itemMstRepository.save(coupon); | ||
} | ||
|
||
} |