Skip to content

Commit

Permalink
Merge pull request #9 from nove1080/feat/7/payment-data-modeling
Browse files Browse the repository at this point in the history
feat: 결제 시스템 Entity 설계 #7
  • Loading branch information
rbm0524 authored Sep 20, 2024
2 parents b08604b + 0896bfe commit d33d011
Show file tree
Hide file tree
Showing 7 changed files with 177 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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; // 재시도 허용 임계값
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.ordertogether.team14_be.payment.domain;

/** 결제 상태 */
public enum PaymentOrderStatus {
READY,
EXECUTING,
SUCCESS,
FAIL;
}
Original file line number Diff line number Diff line change
@@ -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;
}
22 changes: 22 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit d33d011

Please sign in to comment.