Skip to content
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

Merged
merged 5 commits into from
May 9, 2024

Conversation

TaeyeonRoyce
Copy link
Member

📌 관련 이슈

📁 작업 설명

주문번호로 조회시, 상세 주문 내역 응답 API를 개발했습니다.

📸 작업화면

응답 예시

{
    "orderNumber": "20240502000307AAAA7513EFAD",
    "orderedAt": "2024-05-02T00:03:07.685322",
    "orderProducts": [
        {
            "orderId": 1,
            "orderStatus": "ORDER_CREATED",
            "productId": 1,
            "storeId": 1,
            "storeName": "storeA",
            "thumbnail": "image.jpg",
            "productName": "1",
            "quantity": 1,
            "sex": "FEMALE",
            "orderPrice": 1,
            "price": 1,
            "deliveryFee": 3000,
            "deliveryMethod": "COMMON"
        },
        {
            "orderId": 2,
            "orderStatus": "ORDER_CREATED",
            "productId": 2,
            "storeId": 1,
            "storeName": "storeA",
            "thumbnail": "image.jpg",
            "productName": "2",
            "quantity": 1,
            "sex": "MALE",
            "orderPrice": 1,
            "price": 1,
            "deliveryFee": 3000,
            "deliveryMethod": "COMMON"
        }
    ],
    "totalAmount": 3002
}

@TaeyeonRoyce TaeyeonRoyce self-assigned this May 1, 2024
Copy link
Contributor

@hgo641 hgo641 left a 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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

좋네요.....

Copy link
Contributor

@Combi153 Combi153 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주문번호로 조회하는 api 개발 고생하셨습니다!
코드가 깔끔해서 읽기 편했어요 👍

스웨거에서도 테스트를 해보았는데 잘 되네요 😃
간단한 수정만 해주시면 될 것 같아요

Comment on lines +571 to +575
Given("주문 내역을 조회 할 때") {
val accessToken = signInAsMember().accessToken
val memberId = getMemberIdByAccessToken(accessToken)

val storeA = storeRepository.save(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

꼼꼼 테스트 좋아요 👍

Comment on lines +163 to +167
@Schema(
description = "주문 id",
example = "1"
)
val orderId: Long,
Copy link
Contributor

@Combi153 Combi153 May 3, 2024

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 를 변경하면 될 것 같습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

통일해서 사용 하도록 할게요!
저도 작성하면서 헷갈리더라고요! 감사합니다

Comment on lines +35 to +36
@Query("SELECT op FROM OrderPayment op WHERE op.orderId = :orderId ORDER BY op.id DESC LIMIT 1")
fun findOrderStatusByOrderId(orderId: Long): OrderPayment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최신 주문 상태만 깔끔하게 가져오는 게 멋지네요 👍

Comment on lines 85 to 92
companion object {
fun from(memberId: Long, orderNumber: String): OrderDetailReadQuery {
return OrderDetailReadQuery(
memberId = memberId,
orderNumber = OrderNumber(orderNumber),
)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

변수가 하나일 때 from 을 쓰는 게 컨벤션으로 기억해요!

Comment on lines +140 to +150
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,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

깔끔하네요 👍

Copy link

github-actions bot commented May 8, 2024

Test Results

 59 files  ±0   59 suites  ±0   24s ⏱️ +2s
285 tests +2  285 ✅ +2  0 💤 ±0  0 ❌ ±0 
398 runs  +6  398 ✅ +6  0 💤 ±0  0 ❌ ±0 

Results for commit f395bd7. ± Comparison against base commit 1390f7f.

@TaeyeonRoyce TaeyeonRoyce merged commit 92681b6 into develop May 9, 2024
2 checks passed
@TaeyeonRoyce TaeyeonRoyce deleted the 124-feature-주문-상세-내역-조회-api branch May 9, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feature: 주문 상세 내역 조회 API
3 participants