Skip to content

Commit

Permalink
feat: 주문 상세 내역 조회 API
Browse files Browse the repository at this point in the history
  • Loading branch information
TaeyeonRoyce committed May 1, 2024
1 parent 918a49e commit 8bcee63
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main/kotlin/com/petqua/presentation/order/OrderController.kt
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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<OrderDetailResponse> {
val query = OrderDetailReadQuery.from(loginMember.memberId, orderNumber)
val response = orderService.readDetail(query)
return ResponseEntity.ok(response)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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()
}
}

0 comments on commit 8bcee63

Please sign in to comment.