diff --git a/common/src/main/java/org/example/entity/OrderItem.java b/common/src/main/java/org/example/entity/OrderItem.java index 268070c..f490d82 100644 --- a/common/src/main/java/org/example/entity/OrderItem.java +++ b/common/src/main/java/org/example/entity/OrderItem.java @@ -1,30 +1,20 @@ package org.example.entity; -import java.time.LocalDateTime; -import java.util.HashMap; -import java.util.Map; - -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.FetchType; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToOne; - +import io.hypersistence.utils.hibernate.type.json.JsonType; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.example.config.PostgreSQLEnumType; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; -import io.hypersistence.utils.hibernate.type.json.JsonType; -import lombok.Getter; -import lombok.NoArgsConstructor; +import javax.persistence.*; +import java.time.LocalDateTime; +import java.util.HashMap; +import java.util.Map; @Getter +@Setter @Entity @TypeDef(name = "json", typeClass = JsonType.class) @TypeDef(name = "psql_enum", typeClass = PostgreSQLEnumType.class) @@ -113,13 +103,13 @@ public class OrderItem { private Coupon coupons; public OrderItem(Product product, Long orderItemTotalPaymentAmount, Long orderQuantity, - Long orderItemTotalAmount, Long productDiscountAmount, LocalDateTime orderStatusDate, - OrderStatus orderStatus, Long deliveryFee, Long baseShippingFee, Long jejuShippingFee, - Long islandShippingFee, Long originJejuShippingFee, Long originIslandShippingFee, - Long originBaseShippingFee, Long conditionalFreeDeliveryFeeStandardByShop, - boolean isAcceptedConditionalFreeDeliveryFee, - Long originalDeliveryFeeBeforeDeliveryDiscount, Shop shop, - ProductOption userSelectOption) { + Long orderItemTotalAmount, Long productDiscountAmount, LocalDateTime orderStatusDate, + OrderStatus orderStatus, Long deliveryFee, Long baseShippingFee, Long jejuShippingFee, + Long islandShippingFee, Long originJejuShippingFee, Long originIslandShippingFee, + Long originBaseShippingFee, Long conditionalFreeDeliveryFeeStandardByShop, + boolean isAcceptedConditionalFreeDeliveryFee, + Long originalDeliveryFeeBeforeDeliveryDiscount, Shop shop, + ProductOption userSelectOption) { this.product = product; this.orderItemTotalPaymentAmount = orderItemTotalPaymentAmount; this.orderQuantity = orderQuantity; @@ -146,14 +136,14 @@ public OrderItem(Product product, Long orderItemTotalPaymentAmount, Long orderQu public Map getOrderItemOption(ProductOption productOption, long orderQuantity) { if (productOption != null) { return Map.of("optionId", productOption.getOptionId(), - "optionName1", productOption.getOptionName1(), - "optionValue1", productOption.getOptionValue1(), - "optionName2", productOption.getOptionName2(), - "optionValue2", productOption.getOptionValue2(), - "optionName3", productOption.getOptionName3(), - "optionValue3", productOption.getOptionValue3(), - "optionPrice", productOption.getOptionPrice(), - "orderQuantity", orderQuantity + "optionName1", productOption.getOptionName1(), + "optionValue1", productOption.getOptionValue1(), + "optionName2", productOption.getOptionName2(), + "optionValue2", productOption.getOptionValue2(), + "optionName3", productOption.getOptionName3(), + "optionValue3", productOption.getOptionValue3(), + "optionPrice", productOption.getOptionPrice(), + "orderQuantity", orderQuantity ); } else { return Map.of("orderQuantity", orderQuantity); @@ -181,7 +171,7 @@ public void setAcceptedConditionalFreeDeliveryFee(boolean acceptedConditionalFre } public void setAcceptedConditionalFreeDeliveryFeeWhenOrder( - boolean acceptedConditionalFreeDeliveryFeeWhenOrder) { + boolean acceptedConditionalFreeDeliveryFeeWhenOrder) { isAcceptedConditionalFreeDeliveryFeeWhenOrder = acceptedConditionalFreeDeliveryFeeWhenOrder; } @@ -218,6 +208,6 @@ public void setOrderStatusToComplete() { } public Long getOptionId() { - return (Long)this.options.get("optionId"); + return (Long) this.options.get("optionId"); } } diff --git a/web/src/main/java/org/example/dto/CreateMemberOrderResponseDto.java b/web/src/main/java/org/example/dto/CreateMemberOrderResponseDto.java index aa51314..d538e4d 100644 --- a/web/src/main/java/org/example/dto/CreateMemberOrderResponseDto.java +++ b/web/src/main/java/org/example/dto/CreateMemberOrderResponseDto.java @@ -9,22 +9,17 @@ public class CreateMemberOrderResponseDto { private boolean ok; - private Order results; + private OrderResponse results; private boolean isZeroPaidOrder; - public CreateMemberOrderResponseDto(boolean ok, Order results, boolean isZeroPaidOrder) { + public CreateMemberOrderResponseDto(boolean ok, Order order, boolean isZeroPaidOrder) { this.ok = ok; - this.results = results; + this.results = this.toDto(order); this.isZeroPaidOrder = isZeroPaidOrder; } - @Override - public String toString() { - return "CreateMemberOrderOutputDTO{" + - "ok=" + ok + - ", results=" + results + - ", isZeroPaidOrder=" + isZeroPaidOrder + - '}'; + private OrderResponse toDto(Order order) { + return new OrderResponse(order); } } diff --git a/web/src/main/java/org/example/dto/OrderResponse.java b/web/src/main/java/org/example/dto/OrderResponse.java new file mode 100644 index 0000000..d124212 --- /dev/null +++ b/web/src/main/java/org/example/dto/OrderResponse.java @@ -0,0 +1,95 @@ +package org.example.dto; + +import lombok.Getter; +import lombok.Setter; +import org.example.entity.DeliveryType; +import org.example.entity.Order; +import org.example.entity.OrderCustomerType; +import org.example.entity.PaymentMethod; + +import java.time.LocalDateTime; + +@Getter +@Setter +public class OrderResponse { + private long id; + + private String orderName; + + private String orderNumber; + + private Long totalOriginalPrice; + + private Long totalDiscountPrice; + + private Long productDiscountPrice; + + private Long pointDiscountPrice; + + private Long couponDiscountPrice; + + private Long deliveryFee; + + private PaymentMethod paymentMethod; + + private OrderCustomerType orderCustomerType; + + private DeliveryType deliveryType; + + private String refundBankAccount; + + private String refundAccountBankName; + + private String refundAccountHolder; + + private String deliveryMessage; + + private String deliveryPhoneNumber; + + private String receiver; + + private String streetAddress; + + private String detailAddress; + + private String zipCode; + + private LocalDateTime paymentDate; + + private String customerEmail; + + private String customerName; + + private String customerPhoneNumber; + + private String customerPersonalCustomsCode; + + + public OrderResponse(Order order) { + this.id = order.getId(); + this.orderName = order.getOrderName(); + this.orderNumber = order.getOrderNumber(); + this.totalOriginalPrice = order.getTotalOriginalPrice(); + this.totalDiscountPrice = order.getTotalDiscountPrice(); + this.productDiscountPrice = order.getProductDiscountPrice(); + this.pointDiscountPrice = order.getPointDiscountPrice(); + this.couponDiscountPrice = order.getCouponDiscountPrice(); + this.deliveryFee = order.getDeliveryFee(); + this.paymentMethod = order.getPaymentMethod(); + this.orderCustomerType = order.getOrderCustomerType(); + this.deliveryType = order.getDeliveryType(); + this.refundBankAccount = order.getRefundBankAccount(); + this.refundAccountBankName = order.getRefundAccountBankName(); + this.refundAccountHolder = order.getRefundAccountHolder(); + this.deliveryMessage = order.getDeliveryMessage(); + this.deliveryPhoneNumber = order.getDeliveryPhoneNumber(); + this.receiver = order.getReceiver(); + this.streetAddress = order.getStreetAddress(); + this.detailAddress = order.getDetailAddress(); + this.paymentDate = order.getPaymentDate(); + this.customerEmail = order.getCustomerEmail(); + this.customerName = order.getCustomerName(); + this.customerPhoneNumber = order.getCustomerPhoneNumber(); + this.customerPersonalCustomsCode = order.getCustomerPersonalCustomsCode(); + } +} diff --git a/web/src/main/java/org/example/interceptor/RequestHeaderInterceptor.java b/web/src/main/java/org/example/interceptor/RequestHeaderInterceptor.java index 28bfa8c..899bc66 100644 --- a/web/src/main/java/org/example/interceptor/RequestHeaderInterceptor.java +++ b/web/src/main/java/org/example/interceptor/RequestHeaderInterceptor.java @@ -1,22 +1,25 @@ package org.example.interceptor; -import java.util.Collections; - import org.springframework.context.annotation.Configuration; import org.springframework.graphql.server.WebGraphQlInterceptor; import org.springframework.graphql.server.WebGraphQlRequest; import org.springframework.graphql.server.WebGraphQlResponse; - import reactor.core.publisher.Mono; +import java.util.Collections; + @Configuration public class RequestHeaderInterceptor implements WebGraphQlInterceptor { @Override public Mono intercept(WebGraphQlRequest request, Chain chain) { String value = request.getHeaders().getFirst("x-jwt"); + if (value == null) { + return chain.next(request); + } + request.configureExecutionInput((executionInput, builder) -> - builder.graphQLContext(Collections.singletonMap("x-jwt", value)).build()); + builder.graphQLContext(Collections.singletonMap("x-jwt", value)).build()); return chain.next(request); } diff --git a/web/src/main/java/org/example/resolver/OrderResolver.java b/web/src/main/java/org/example/resolver/OrderResolver.java index 720809d..41b6c87 100644 --- a/web/src/main/java/org/example/resolver/OrderResolver.java +++ b/web/src/main/java/org/example/resolver/OrderResolver.java @@ -13,6 +13,7 @@ import org.springframework.graphql.data.method.annotation.Argument; import org.springframework.graphql.data.method.annotation.ContextValue; import org.springframework.graphql.data.method.annotation.MutationMapping; +import org.springframework.graphql.data.method.annotation.QueryMapping; import org.springframework.stereotype.Controller; @Controller @@ -27,7 +28,7 @@ public class OrderResolver { public CreateMemberOrderResponseDto createMemberOrderV3( @Argument("input") CreateMemberOrderRequestDto requestDto, @ContextValue(name = "x-jwt") String jwtAccessToken) throws Exception { - if (!this.jwtService.verifyToken(jwtAccessToken)) { + if (jwtAccessToken != null && !this.jwtService.verifyToken(jwtAccessToken)) { throw new GraphqlException("403 FORBIDDEN"); } @@ -45,4 +46,9 @@ public CreateMemberOrderResponseDto createMemberOrderV3( return new CreateMemberOrderResponseDto(true, newOrder, false); } + + @QueryMapping + public String healthCheck() { + return "hello"; + } } diff --git a/web/src/main/resources/graphql/output.graphqls b/web/src/main/resources/graphql/output.graphqls index bd31126..0c086fa 100644 --- a/web/src/main/resources/graphql/output.graphqls +++ b/web/src/main/resources/graphql/output.graphqls @@ -3,15 +3,3 @@ type CreateOrderV3Output { results: Order isZeroPaidOrder: Boolean } - -type MemberOrderOutput { - error: String - ok: Boolean! - results: OrderInfo -} - -type ConfirmMemberOrderOutput { - error: String - ok: Boolean! - results: Boolean -} diff --git a/web/src/main/resources/graphql/schema.graphqls b/web/src/main/resources/graphql/schema.graphqls index 2740a8e..92a4688 100644 --- a/web/src/main/resources/graphql/schema.graphqls +++ b/web/src/main/resources/graphql/schema.graphqls @@ -1,10 +1,9 @@ type Mutation { createMemberOrderV3(input: CreateOrderV3Input!): CreateOrderV3Output! - confirmMemberOrder(input: ConfirmMemberOrderInput!): ConfirmMemberOrderOutput! } type Query { - order(input: MemberOrderInput!): MemberOrderOutput! + healthCheck: String! } scalar DateTime diff --git a/web/src/main/resources/graphql/type.graphqls b/web/src/main/resources/graphql/type.graphqls index 191da05..51554d9 100644 --- a/web/src/main/resources/graphql/type.graphqls +++ b/web/src/main/resources/graphql/type.graphqls @@ -1,24 +1,14 @@ -type OrderInfo { - order: Order - payment: Payment -} - type Order { id: Int! createdAt: DateTime! updatedAt: DateTime! orderNumber: String! - customer: User - items: [OrderItem!]! totalOriginalPrice: Int! totalDiscountPrice: Int! productDiscountPrice: Int pointDiscountPrice: Int couponDiscountPrice: Int deliveryFee: Int! - user: User - product: [Product!] - shop: Shop orderItemVat: Int finalPrice: Int finalPurchasePrice: Int