Skip to Content
Suffering builds character

4.상품 상세조회

누구나 상품 상세 정보를 조회할 수 있음

메서드URI
GET/api/products/{id}

1-1. 세부 요구사항

  • HATEOAS 링크 포함(_links)
    • profile: 상품 상세 조회에 대한 API 문서 참조 링크
    • self: 현재 조회한 데이터 자체 API
    • 인증된 사용자 중에서 자신이 등록한 상품일 경우, update, delete 링크도 추가 응답
    • 인증된 사용자이고, 상품의 재고가 있을 경우 상품을 주문할 수 있는 order 링크도 추가 응답

1-2. 요청 예시

요청 예시는 다음과 같음

HTTP 요청 포맷
// 상품 id가 1번인 상품 조회 GET {host}/api/products/1

1-3. 응답 예시

응답 예시는 다음과 같음

자신이 등록한 상품일 경우(update, delete 링크 포함)

JSON 응답 포맷
{ "id": 1, "name": "아이팟 프로", "description": "아이맥입니다", "price": 120000, "stock": 3, "category": "전자제품", "userId": 1, "_links": { "self": { "href": "http://localhost:8080/api/products/1" }, "profile": { "href": "/swagger-ui/index.html" }, "order": { "href": "/api/orders", "type": "POST" }, "update-product": { "href": "http://localhost:8080/api/products/1", "type": "PUT" }, "delete-product": { "href": "http://localhost:8080/api/products/1", "type": "DELETE" } } }

자신이 등록하지 않은 상품일 경우(update, delete 링크 미포함)

JSON 응답 포맷
{ "id": 1, "name": "아이팟 프로", "description": "아이맥입니다", "price": 120000, "stock": 3, "category": "전자제품", "userId": 1, "_links": { "self": { "href": "http://localhost:8080/api/products/1" }, "profile": { "href": "/swagger-ui/index.html" } } }
Last updated on