-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'weekly_4' into feat/27/swagger
- Loading branch information
Showing
48 changed files
with
1,110 additions
and
141 deletions.
There are no files selected for viewing
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
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
12 changes: 12 additions & 0 deletions
12
src/main/java/com/ordertogether/team14_be/common/util/IdempotentKeyGenerator.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,12 @@ | ||
package com.ordertogether.team14_be.common.util; | ||
|
||
import java.util.UUID; | ||
import lombok.experimental.UtilityClass; | ||
|
||
@UtilityClass | ||
public final class IdempotentKeyGenerator { | ||
|
||
public static String generate(String seed) { | ||
return UUID.nameUUIDFromBytes(seed.getBytes()).toString(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/ordertogether/team14_be/common/web/response/ApiResponse.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,20 @@ | ||
package com.ordertogether.team14_be.common.web.response; | ||
|
||
import jakarta.annotation.Nullable; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class ApiResponse<T> { | ||
|
||
private Integer status; | ||
private String message; | ||
private T data; | ||
|
||
public static <T> ApiResponse<T> with(HttpStatus httpStatus, String message, @Nullable T data) { | ||
return new ApiResponse<>(httpStatus.value(), message, data); | ||
} | ||
} |
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
6 changes: 3 additions & 3 deletions
6
...br/application/service/MemberService.java → ...er/application/service/MemberService.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
4 changes: 2 additions & 2 deletions
4
.../memebr/persistence/MemberRepository.java → .../member/persistence/MemberRepository.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
2 changes: 1 addition & 1 deletion
2
..._be/memebr/persistence/entity/Member.java → ..._be/member/persistence/entity/Member.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
39 changes: 16 additions & 23 deletions
39
src/main/java/com/ordertogether/team14_be/payment/domain/PaymentEvent.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 |
---|---|---|
@@ -1,41 +1,34 @@ | ||
package com.ordertogether.team14_be.payment.domain; | ||
|
||
import com.ordertogether.team14_be.common.persistence.entity.BaseTimeEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import java.math.BigDecimal; | ||
import java.util.List; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Entity | ||
@Builder | ||
@Getter | ||
@SuperBuilder | ||
@ToString | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PaymentEvent extends BaseTimeEntity { | ||
public class PaymentEvent { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Long buyerId; // 구매자 식별자 | ||
private Long buyerId; | ||
|
||
private List<PaymentOrder> paymentOrders; | ||
|
||
@Column(nullable = false) | ||
private String orderId; | ||
|
||
private String orderName; | ||
|
||
@Column(nullable = false) | ||
private String paymentKey; // PSP 결제 식별자 | ||
private String paymentKey; | ||
|
||
@Builder.Default private PaymentStatus paymentStatus = PaymentStatus.READY; | ||
|
||
@Builder.Default private Boolean isPaymentDone = false; | ||
public Long totalAmount() { | ||
return paymentOrders.stream() | ||
.map(PaymentOrder::getAmount) | ||
.reduce(BigDecimal.ZERO, BigDecimal::add) | ||
.longValue(); | ||
} | ||
} |
57 changes: 23 additions & 34 deletions
57
src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrder.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 |
---|---|---|
@@ -1,53 +1,42 @@ | ||
package com.ordertogether.team14_be.payment.domain; | ||
|
||
import com.ordertogether.team14_be.common.persistence.entity.BaseTimeEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.ManyToOne; | ||
import java.math.BigDecimal; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import java.util.Objects; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Entity | ||
@Builder | ||
@Getter | ||
@SuperBuilder | ||
@ToString | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PaymentOrder extends BaseTimeEntity { | ||
public class PaymentOrder { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Long sellerId; // 판매자 식별자 | ||
private Long productId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
private Product productId; | ||
|
||
@Column(nullable = false) | ||
private String orderId; | ||
|
||
@Column(precision = 10, scale = 2) | ||
private BigDecimal amount; // 결제 금액 | ||
private String orderName; | ||
|
||
private BigDecimal amount; | ||
|
||
public PaymentOrder updateProductInfo(Product product) { | ||
if (isProductMismatch(product)) { | ||
throw new IllegalArgumentException("상품 정보가 일치하지 않습니다."); | ||
} | ||
|
||
this.orderName = product.getName(); | ||
this.amount = product.getPrice(); | ||
|
||
@Enumerated(EnumType.STRING) | ||
@Builder.Default | ||
private PaymentOrderStatus paymentOrderStatus = PaymentOrderStatus.READY; | ||
return this; | ||
} | ||
|
||
@Builder.Default private Byte retryCount = 0; // 재시도 횟수 | ||
public boolean isMissingProductInfo() { | ||
return Objects.isNull(orderName) && Objects.isNull(amount); | ||
} | ||
|
||
@Builder.Default private Byte retryThreshold = 5; // 재시도 허용 임계값 | ||
private boolean isProductMismatch(Product product) { | ||
return !Objects.equals(productId, product.getId()); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/main/java/com/ordertogether/team14_be/payment/domain/PaymentOrderStatus.java
This file was deleted.
Oops, something went wrong.
16 changes: 16 additions & 0 deletions
16
src/main/java/com/ordertogether/team14_be/payment/domain/PaymentStatus.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.ordertogether.team14_be.payment.domain; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
/** 결제 상태 */ | ||
@Getter | ||
@RequiredArgsConstructor | ||
public enum PaymentStatus { | ||
READY("결제 준비"), | ||
EXECUTING("결제 진행 중"), | ||
SUCCESS("결제 성공"), | ||
FAIL("결제 실패"); | ||
|
||
private final String description; | ||
} |
22 changes: 3 additions & 19 deletions
22
src/main/java/com/ordertogether/team14_be/payment/domain/Product.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 |
---|---|---|
@@ -1,34 +1,18 @@ | ||
package com.ordertogether.team14_be.payment.domain; | ||
|
||
import com.ordertogether.team14_be.common.persistence.entity.BaseTimeEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
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 | ||
@Builder | ||
@Getter | ||
@SuperBuilder | ||
@ToString | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class Product extends BaseTimeEntity { | ||
public class Product { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
@Column(nullable = false) | ||
private BigDecimal price; | ||
} |
49 changes: 49 additions & 0 deletions
49
...n/java/com/ordertogether/team14_be/payment/persistence/jpa/entity/PaymentEventEntity.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,49 @@ | ||
package com.ordertogether.team14_be.payment.persistence.jpa.entity; | ||
|
||
import com.ordertogether.team14_be.common.persistence.entity.BaseTimeEntity; | ||
import com.ordertogether.team14_be.payment.domain.PaymentStatus; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.EnumType; | ||
import jakarta.persistence.Enumerated; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
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 | ||
@Table(name = "payment_event") | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
@NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
public class PaymentEventEntity extends BaseTimeEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Long buyerId; // 구매자 식별자 | ||
|
||
@Column(nullable = false) | ||
private String orderId; | ||
|
||
@Column(nullable = false) | ||
private String orderName; | ||
|
||
@Column(nullable = false) | ||
private String paymentKey; // PSP 결제 식별자 | ||
|
||
@Builder.Default | ||
@Enumerated(EnumType.STRING) | ||
private PaymentStatus paymentStatus = PaymentStatus.READY; | ||
} |
Oops, something went wrong.