diff --git a/src/main/kotlin/com/petqua/presentation/order/OrderController.kt b/src/main/kotlin/com/petqua/presentation/order/OrderController.kt index 48bcf378..bbb356a9 100644 --- a/src/main/kotlin/com/petqua/presentation/order/OrderController.kt +++ b/src/main/kotlin/com/petqua/presentation/order/OrderController.kt @@ -1,19 +1,23 @@ package com.petqua.presentation.order import com.petqua.application.order.OrderService +import com.petqua.application.order.dto.OrderDetailReadQuery import com.petqua.application.order.dto.SaveOrderResponse import com.petqua.common.config.ACCESS_TOKEN_SECURITY_SCHEME_KEY import com.petqua.domain.auth.Auth import com.petqua.domain.auth.LoginMember +import com.petqua.presentation.order.dto.OrderDetailResponse import com.petqua.presentation.order.dto.SaveOrderRequest import io.swagger.v3.oas.annotations.Operation import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.security.SecurityRequirement import io.swagger.v3.oas.annotations.tags.Tag import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @SecurityRequirement(name = ACCESS_TOKEN_SECURITY_SCHEME_KEY) @@ -34,4 +38,16 @@ class OrderController( val response = orderService.save(request.toCommand(loginMember.memberId)) return ResponseEntity.ok(response) } + + @Operation(summary = "주문 상세 조회 API", description = "주문 상세를 조회합니다") + @ApiResponse(responseCode = "200", description = "주문 상세 조회 성공") + @GetMapping + fun readDetail( + @Auth loginMember: LoginMember, + @RequestParam orderNumber: String, + ): ResponseEntity { + val query = OrderDetailReadQuery.from(loginMember.memberId, orderNumber) + val response = orderService.readDetail(query) + return ResponseEntity.ok(response) + } } diff --git a/src/test/kotlin/com/petqua/presentation/order/OrderControllerSteps.kt b/src/test/kotlin/com/petqua/presentation/order/OrderControllerSteps.kt index 968c75dd..35afc441 100644 --- a/src/test/kotlin/com/petqua/presentation/order/OrderControllerSteps.kt +++ b/src/test/kotlin/com/petqua/presentation/order/OrderControllerSteps.kt @@ -1,5 +1,6 @@ package com.petqua.presentation.order +import com.petqua.application.order.dto.SaveOrderResponse import com.petqua.presentation.order.dto.SaveOrderRequest import io.restassured.module.kotlin.extensions.Extract import io.restassured.module.kotlin.extensions.Given @@ -25,3 +26,40 @@ fun requestSaveOrder( response() } } + +fun requestOrderAndReturnOrderNumber( + request: SaveOrderRequest, + accessToken: String, +): String { + val response = Given { + log().all() + body(request) + auth().preemptive().oauth2(accessToken) + contentType(APPLICATION_JSON_VALUE) + } When { + post("/orders") + } Then { + log().all() + } Extract { + response() + } + + return response.`as`(SaveOrderResponse::class.java).orderId +} + +fun requestReadOrderDetail( + orderNumber: String, + accessToken: String, +): Response { + return Given { + log().all() + auth().preemptive().oauth2(accessToken) + .queryParams("orderNumber", orderNumber) + } When { + get("/orders") + } Then { + log().all() + } Extract { + response() + } +}