diff --git a/src/main/java/com/flow/payment/dto/order/OrdersDto.java b/src/main/java/com/flow/payment/dto/order/OrdersDto.java index 7331728..a819236 100644 --- a/src/main/java/com/flow/payment/dto/order/OrdersDto.java +++ b/src/main/java/com/flow/payment/dto/order/OrdersDto.java @@ -16,7 +16,7 @@ public class OrdersDto { private Long orderId; - private Long userId; + private Long coffeeId; private UUID tossOrderId; private UUID customerKey; private LocalDateTime orderDate; diff --git a/src/main/java/com/flow/payment/dto/order/request/OrdersRequestDto.java b/src/main/java/com/flow/payment/dto/order/request/OrdersRequestDto.java index 8eded39..ad0ba48 100644 --- a/src/main/java/com/flow/payment/dto/order/request/OrdersRequestDto.java +++ b/src/main/java/com/flow/payment/dto/order/request/OrdersRequestDto.java @@ -19,7 +19,7 @@ @AllArgsConstructor public class OrdersRequestDto { - private String email; + private Long coffeeId; private BigDecimal totalAmount; } diff --git a/src/main/java/com/flow/payment/dto/order/response/OrdersResponseDto.java b/src/main/java/com/flow/payment/dto/order/response/OrdersResponseDto.java index 9105447..c622fa9 100644 --- a/src/main/java/com/flow/payment/dto/order/response/OrdersResponseDto.java +++ b/src/main/java/com/flow/payment/dto/order/response/OrdersResponseDto.java @@ -17,6 +17,7 @@ @NoArgsConstructor @AllArgsConstructor public class OrdersResponseDto { + private Long orderId; private UUID customerKey; private String tossOrderId; } diff --git a/src/main/java/com/flow/payment/dto/payment/request/PaymentsConfirmRequestDto.java b/src/main/java/com/flow/payment/dto/payment/request/PaymentsConfirmRequestDto.java index 75a269e..ca84bb9 100644 --- a/src/main/java/com/flow/payment/dto/payment/request/PaymentsConfirmRequestDto.java +++ b/src/main/java/com/flow/payment/dto/payment/request/PaymentsConfirmRequestDto.java @@ -23,6 +23,7 @@ public class PaymentsConfirmRequestDto { private String paymentKey; - @JsonProperty("orderId") + @JsonProperty("tossOrderId") private String tossOrderId; + } diff --git a/src/main/java/com/flow/payment/entity/OrdersEntity.java b/src/main/java/com/flow/payment/entity/OrdersEntity.java index 7ed69c5..f4ca39e 100644 --- a/src/main/java/com/flow/payment/entity/OrdersEntity.java +++ b/src/main/java/com/flow/payment/entity/OrdersEntity.java @@ -35,8 +35,8 @@ public class OrdersEntity extends BaseEntity { @Column(name = "order_id") private Long orderId; - @Column(name = "user_id", nullable = false) - private Long userId; + @Column(name = "coffee_id", nullable = false) + private Long coffeeId; @Column(name = "toss_order_id", nullable = false) private UUID tossOrderId; diff --git a/src/main/java/com/flow/payment/entity/PaymentLogsEntity.java b/src/main/java/com/flow/payment/entity/PaymentLogsEntity.java deleted file mode 100644 index 88edeba..0000000 --- a/src/main/java/com/flow/payment/entity/PaymentLogsEntity.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.flow.payment.entity; - -import java.util.Map; - -import org.hibernate.annotations.JdbcTypeCode; -import org.hibernate.annotations.Where; -import org.hibernate.type.SqlTypes; - -import com.flow.payment.common.entity.BaseEntity; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.Table; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.experimental.SuperBuilder; - -@Entity -@Getter -@Setter -@AllArgsConstructor -@NoArgsConstructor -@SuperBuilder -@Table(name = "payment_logs") -@Where(clause = "use_yn = true") -public class PaymentLogsEntity extends BaseEntity { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "log_id") - private Long logId; - - @Column(name = "order_id", nullable = false) - private Long orderId; - - @Column(name = "event_type", nullable = false, length = 50) - private String eventType; - - @Column(name = "request") - @JdbcTypeCode(SqlTypes.JSON) - private Map request; - - @Column(name = "response") - @JdbcTypeCode(SqlTypes.JSON) - private Map response; - -} diff --git a/src/main/java/com/flow/payment/mapper/OrdersMapper.java b/src/main/java/com/flow/payment/mapper/OrdersMapper.java index c2c3163..4d05a25 100644 --- a/src/main/java/com/flow/payment/mapper/OrdersMapper.java +++ b/src/main/java/com/flow/payment/mapper/OrdersMapper.java @@ -17,12 +17,12 @@ @Mapper(componentModel = "spring", imports = {LocalDateTime.class, UUID.class}) public interface OrdersMapper extends GenericMapper { - @Mapping(target = "userId", source = "user.userId") + @Mapping(target = "coffeeId", source = "coffeeId") @Mapping(target = "orderDate", expression = "java(LocalDateTime.now())") @Mapping(target = "tossOrderId", expression = "java(UUID.randomUUID())") @Mapping(target = "customerKey", expression = "java(UUID.randomUUID())") @Mapping(target = "status", constant = "주문서 생성") - OrdersDto toOrdersDto(OrdersRequestDto ordersRequestDto, UsersDto user); + OrdersDto toOrdersDto(OrdersRequestDto ordersRequestDto); OrdersResponseDto toOrdersResponseDto(OrdersDto savedOrder); diff --git a/src/main/java/com/flow/payment/service/orders/OrdersCreateService.java b/src/main/java/com/flow/payment/service/orders/OrdersCreateService.java index 2508730..e3e3a6f 100644 --- a/src/main/java/com/flow/payment/service/orders/OrdersCreateService.java +++ b/src/main/java/com/flow/payment/service/orders/OrdersCreateService.java @@ -25,13 +25,9 @@ public class OrdersCreateService { private final OrdersService ordersService; private final OrdersMapper ordersMapper; - public OrdersResponseDto create(OrdersRequestDto ordersRequestDto) { - // 사용자 정보를 이메일로 찾기 - UsersDto user = usersService.findUsersByEmail(ordersRequestDto.getEmail()); - // 주문 정보를 생성 및 저장 - OrdersDto newOrder = ordersMapper.toOrdersDto(ordersRequestDto, user); + OrdersDto newOrder = ordersMapper.toOrdersDto(ordersRequestDto); OrdersDto savedOrder = ordersService.save(newOrder); // 응답 DTO 생성 및 반환 diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index ca5ae54..2083b2e 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -12,10 +12,6 @@ spring: hibernate: ddl-auto: none # Hibernate DDL (none, validate, update, create-drop) show-sql: true - properties: - hibernate: - format_sql: true - dialect: org.hibernate.dialect.PostgreSQLDialect toss: payments: widget-secret-key: ${WIDGET_SECRET_KEY} \ No newline at end of file diff --git a/src/test/java/com/flow/payment/order/OrderControllerTest.java b/src/test/java/com/flow/payment/order/OrderControllerTest.java index 627bff7..123c7cb 100644 --- a/src/test/java/com/flow/payment/order/OrderControllerTest.java +++ b/src/test/java/com/flow/payment/order/OrderControllerTest.java @@ -29,9 +29,11 @@ public class OrderControllerTest extends ResourceSnippetIntegrationTest { @Test @DisplayName("주문 생성 성공") void createOrderSuccess() throws Exception { - OrdersRequestDto request = OrdersRequestDto.builder().email("a1061602@gachon.ac.kr").totalAmount( - BigDecimal.valueOf(1000)).build(); + OrdersRequestDto request = OrdersRequestDto.builder() + .coffeeId(1L) + .totalAmount(BigDecimal.valueOf(1000)).build(); OrdersResponseDto response = OrdersResponseDto.builder() + .orderId(1L) .customerKey(UUID.randomUUID()) .tossOrderId(UUID.randomUUID().toString()) .build(); @@ -55,10 +57,11 @@ void createOrderSuccess() throws Exception { .requestSchema(Schema.schema("주문 생성 요청")) .responseSchema(Schema.schema("주문 생성 응답")) .requestFields( - fieldWithPath("email").description("이메일"), + fieldWithPath("coffeeId").description("커피챗 ID"), fieldWithPath("totalAmount").description("총 금액") ) .responseFields( + fieldWithPath("orderId").description("주문서 번호"), fieldWithPath("customerKey").description("고객 번호 (UUID)"), fieldWithPath("tossOrderId").description("토스 주문 번호 (UUID)") ) @@ -69,8 +72,9 @@ void createOrderSuccess() throws Exception { @Test @DisplayName("주문 생성 실패") void createOrderFailByEmail() throws Exception { - OrdersRequestDto request = OrdersRequestDto.builder().email("a1061602@gmail.com").totalAmount( - BigDecimal.valueOf(1000)).build(); + OrdersRequestDto request = OrdersRequestDto.builder() + .coffeeId(1L) + .totalAmount(BigDecimal.valueOf(1000)).build(); given(ordersCreateService.create(request)).willThrow(new CustomNotFoundException()); @@ -90,7 +94,7 @@ void createOrderFailByEmail() throws Exception { .requestSchema(Schema.schema("주문 생성 요청")) .responseSchema(Schema.schema("주문 생성 응답")) .requestFields( - fieldWithPath("email").description("이메일"), + fieldWithPath("coffeeId").description("커피챗 ID"), fieldWithPath("totalAmount").description("총 금액") ) .responseFields() diff --git a/src/test/java/com/flow/payment/order/PaymentControllerTest.java b/src/test/java/com/flow/payment/order/PaymentControllerTest.java index 7f47dfc..f9a344f 100644 --- a/src/test/java/com/flow/payment/order/PaymentControllerTest.java +++ b/src/test/java/com/flow/payment/order/PaymentControllerTest.java @@ -66,7 +66,7 @@ void paymentSuccess() throws Exception { .requestFields( fieldWithPath("paymentKey").description("paymentKey"), fieldWithPath("amount").description("총 금액"), - fieldWithPath("orderId").description("토스 주문 번호 (UUID)") + fieldWithPath("tossOrderId").description("토스 주문 번호 (UUID)") ) .responseFields() .build() @@ -106,7 +106,7 @@ void paymentFail() throws Exception { .requestFields( fieldWithPath("paymentKey").description("paymentKey"), fieldWithPath("amount").description("총 금액"), - fieldWithPath("orderId").description("토스 주문 번호 (UUID)") + fieldWithPath("tossOrderId").description("토스 주문 번호 (UUID)") ) .responseFields() .build()