-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: 주문 상세 내역 조회 api #128
The head ref may contain hidden characters: "124-feature-\uC8FC\uBB38-\uC0C1\uC138-\uB0B4\uC5ED-\uC870\uD68C-api"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다!!
@@ -0,0 +1,10 @@ | |||
package com.petqua.common.util | |||
|
|||
inline fun <reified K, V> Map<K, V>.getOrThrow( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋네요.....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주문번호로 조회하는 api 개발 고생하셨습니다!
코드가 깔끔해서 읽기 편했어요 👍
스웨거에서도 테스트를 해보았는데 잘 되네요 😃
간단한 수정만 해주시면 될 것 같아요
Given("주문 내역을 조회 할 때") { | ||
val accessToken = signInAsMember().accessToken | ||
val memberId = getMemberIdByAccessToken(accessToken) | ||
|
||
val storeA = storeRepository.save( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
꼼꼼 테스트 좋아요 👍
@Schema( | ||
description = "주문 id", | ||
example = "1" | ||
) | ||
val orderId: Long, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SaveOrderResponse DTO 에서는 orderId를 orderNumber 와 같은 의미로 쓰고 있어서요. TossPayment 에 관한 DTO에서도 그렇구요. 오해의 소지가 있는 것 같습니다!
orderId 는 order 엔티티를 구분하는 식별자로 쓰고, 하나의 주문을 구분하는 식별자로 orderNumber 를 쓰면 어떨까요? SaveOrderResponse 를 변경하면 될 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
통일해서 사용 하도록 할게요!
저도 작성하면서 헷갈리더라고요! 감사합니다
@Query("SELECT op FROM OrderPayment op WHERE op.orderId = :orderId ORDER BY op.id DESC LIMIT 1") | ||
fun findOrderStatusByOrderId(orderId: Long): OrderPayment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
최신 주문 상태만 깔끔하게 가져오는 게 멋지네요 👍
companion object { | ||
fun from(memberId: Long, orderNumber: String): OrderDetailReadQuery { | ||
return OrderDetailReadQuery( | ||
memberId = memberId, | ||
orderNumber = OrderNumber(orderNumber), | ||
) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변수가 하나일 때 from 을 쓰는 게 컨벤션으로 기억해요!
fun readDetail(query: OrderDetailReadQuery): OrderDetailResponse { | ||
val orders = orderRepository.findByOrderNumberOrThrow(query.orderNumber) { OrderException(ORDER_NOT_FOUND) } | ||
orders.forEach { it.validateOwner(query.memberId) } | ||
val orderProductResponses = orderProductResponsesFromOrders(orders) | ||
val representativeOrder = orders[0] | ||
return OrderDetailResponse( | ||
orderNumber = representativeOrder.orderNumber.value, | ||
orderedAt = representativeOrder.createdAt, | ||
orderProducts = orderProductResponses, | ||
totalAmount = representativeOrder.totalAmount, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
깔끔하네요 👍
📌 관련 이슈
📁 작업 설명
주문번호로 조회시, 상세 주문 내역 응답 API를 개발했습니다.
📸 작업화면
응답 예시