diff --git a/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java b/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java index f7ee4ee4..fb2e4776 100644 --- a/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java +++ b/src/main/java/com/ordertogether/team14_be/Team14BeApplication.java @@ -2,7 +2,9 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; +@EnableJpaAuditing @SpringBootApplication public class Team14BeApplication { diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/BaseEntity.java b/src/main/java/com/ordertogether/team14_be/payment/domain/BaseEntity.java new file mode 100644 index 00000000..af808584 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/BaseEntity.java @@ -0,0 +1,40 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +@SuperBuilder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@ToString +@Getter +public abstract class BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, updatable = false) + @CreatedDate + private LocalDateTime createdAt; + + @Column(nullable = false) + @LastModifiedDate + private LocalDateTime updatedAt; +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.java b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.java new file mode 100644 index 00000000..5097603e --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.java @@ -0,0 +1,33 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class PaymentEvent extends BaseEntity { + + @Column(nullable = false) + private Long buyerId; // 구매자 식별자 + + @Column(nullable = false) + private String orderId; + + private String orderName; + + @Column(nullable = false) + private String paymentKey; // PSP 결제 식별자 + + @Builder.Default private Boolean isPaymentDone = false; +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.java b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.java new file mode 100644 index 00000000..47f7c92c --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.java @@ -0,0 +1,45 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.FetchType; +import jakarta.persistence.ManyToOne; +import java.math.BigDecimal; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class PaymentOrder extends BaseEntity { + + @Column(nullable = false) + private Long sellerId; // 판매자 식별자 + + @ManyToOne(fetch = FetchType.LAZY) + private Product productId; + + @Column(nullable = false) + private String orderId; + + @Column(precision = 10, scale = 2) + private BigDecimal amount; // 결제 금액 + + @Enumerated(EnumType.STRING) + @Builder.Default + private PaymentOrderStatus paymentOrderStatus = PaymentOrderStatus.READY; + + @Builder.Default private Byte retryCount = 0; // 재시도 횟수 + + @Builder.Default private Byte retryThreshold = 5; // 재시도 허용 임계값 +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java new file mode 100644 index 00000000..d09a7769 --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java @@ -0,0 +1,9 @@ +package com.ordertogether.team14_be.payment.domain; + +/** 결제 상태 */ +public enum PaymentOrderStatus { + READY, + EXECUTING, + SUCCESS, + FAIL; +} diff --git a/src/main/java/com/ordertogether/team14_be/payment/domain/Product.java b/src/main/java/com/ordertogether/team14_be/payment/domain/Product.java new file mode 100644 index 00000000..eb4326ce --- /dev/null +++ b/src/main/java/com/ordertogether/team14_be/payment/domain/Product.java @@ -0,0 +1,26 @@ +package com.ordertogether.team14_be.payment.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import java.math.BigDecimal; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +@Entity +@Getter +@SuperBuilder +@ToString +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class Product extends BaseEntity { + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private BigDecimal price; +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8b0930e7..45727403 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,3 +1,25 @@ spring: application: name: Team14_BE + + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver + username: root + password: + url: jdbc:mysql://localhost:3306/delivery_sharing + + jpa: + hibernate: + ddl-auto: create + properties: + hibernate: + format_sql: true + +logging: + level: + org: + hibernate: + SQL: debug + orm: + jdbc: + bind: trace \ No newline at end of file