카드 매입 승인 경로 Spring Boot 3 전환 #9
1 changed files with 88 additions and 0 deletions
88
src/main/java/com/acquirex/dto/AcquisitionDto.java
Normal file
88
src/main/java/com/acquirex/dto/AcquisitionDto.java
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
package com.acquirex.dto;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 카드 매입 요청/응답 DTO
|
||||
* Spring Boot 3: javax.validation → jakarta.validation
|
||||
*/
|
||||
public class AcquisitionDto {
|
||||
|
||||
// ========== Request DTO ==========
|
||||
public static class Request {
|
||||
@NotBlank(message = "카드번호는 필수입니다")
|
||||
@Size(min = 13, max = 19, message = "카드번호 길이가 올바르지 않습니다")
|
||||
private String cardNumber;
|
||||
|
||||
@NotBlank(message = "가맹점ID는 필수입니다")
|
||||
private String merchantId;
|
||||
|
||||
@NotNull(message = "금액은 필수입니다")
|
||||
@DecimalMin(value = "0.01", message = "금액은 0보다 커야 합니다")
|
||||
@Digits(integer = 13, fraction = 2, message = "금액 형식이 올바르지 않습니다")
|
||||
private BigDecimal amount;
|
||||
|
||||
@NotBlank(message = "통화는 필수입니다")
|
||||
@Size(min = 3, max = 3, message = "통화 코드는 3자리입니다")
|
||||
private String currency;
|
||||
|
||||
public String getCardNumber() { return cardNumber; }
|
||||
public void setCardNumber(String cardNumber) { this.cardNumber = cardNumber; }
|
||||
public String getMerchantId() { return merchantId; }
|
||||
public void setMerchantId(String merchantId) { this.merchantId = merchantId; }
|
||||
public BigDecimal getAmount() { return amount; }
|
||||
public void setAmount(BigDecimal amount) { this.amount = amount; }
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
}
|
||||
|
||||
// ========== Response DTO ==========
|
||||
public static class Response {
|
||||
private Long id;
|
||||
private String approvalCode;
|
||||
private String status;
|
||||
private String message;
|
||||
private BigDecimal amount;
|
||||
private String currency;
|
||||
private LocalDateTime approvalTime;
|
||||
|
||||
public Response() {}
|
||||
|
||||
public static Response success(Long id, String approvalCode, BigDecimal amount, String currency) {
|
||||
Response response = new Response();
|
||||
response.setId(id);
|
||||
response.setApprovalCode(approvalCode);
|
||||
response.setStatus("APPROVED");
|
||||
response.setMessage("매입 승인이 완료되었습니다");
|
||||
response.setAmount(amount);
|
||||
response.setCurrency(currency);
|
||||
response.setApprovalTime(LocalDateTime.now());
|
||||
return response;
|
||||
}
|
||||
|
||||
public static Response rejected(Long id, String reason) {
|
||||
Response response = new Response();
|
||||
response.setId(id);
|
||||
response.setStatus("REJECTED");
|
||||
response.setMessage(reason);
|
||||
return response;
|
||||
}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public void setId(Long id) { this.id = id; }
|
||||
public String getApprovalCode() { return approvalCode; }
|
||||
public void setApprovalCode(String approvalCode) { this.approvalCode = approvalCode; }
|
||||
public String getStatus() { return status; }
|
||||
public void setStatus(String status) { this.status = status; }
|
||||
public String getMessage() { return message; }
|
||||
public void setMessage(String message) { this.message = message; }
|
||||
public BigDecimal getAmount() { return amount; }
|
||||
public void setAmount(BigDecimal amount) { this.amount = amount; }
|
||||
public String getCurrency() { return currency; }
|
||||
public void setCurrency(String currency) { this.currency = currency; }
|
||||
public LocalDateTime getApprovalTime() { return approvalTime; }
|
||||
public void setApprovalTime(LocalDateTime approvalTime) { this.approvalTime = approvalTime; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue