티스토리 뷰

Project

order-api

ryumodern 2021. 10. 25. 19:19
주문

주문 내역 조회

Request

CURL

$ curl 'https://localhost:8443/api/orders?memberId=3' -i -X GET \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*'

HTTPie

$ http GET 'https://localhost:8443/api/orders?memberId=3' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request HTTP Example

GET /api/orders?memberId=3 HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Host: localhost:8443

Response

Response Fields

필드 타입 필수값 설명 제한

_embedded.orderResponseList[].id

Number

true

주문 번호

_embedded.orderResponseList[].orderStatus

String

true

주문 상태

_embedded.orderResponseList[].orderProducts

Array

true

주문 상품 목록

_embedded.orderResponseList[].delivery

Object

true

배송 정보

_embedded.orderResponseList[].memberResponse

Object

true

주문 회원

_links

Object

true

HATEOAS

page

Object

true

페이지 설정

Response HTTP Example

HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN
Content-Length: 1905

{
  "_embedded" : {
    "orderResponseList" : [ {
      "id" : 1,
      "memberResponse" : {
        "id" : 3,
        "email" : "panda@naver.com",
        "nickname" : "panda",
        "profileImage" : null,
        "phone" : "01012345678",
        "license" : null,
        "createdDateTime" : "2021-10-25T01:13:36.084193",
        "lastModifiedDateTime" : "2021-10-25T01:13:36.084193",
        "leaveDateTime" : null,
        "authority" : null,
        "address" : {
          "city" : "seoul",
          "street" : "yeonhui",
          "zipcode" : "01023"
        },
        "authProvider" : null,
        "status" : "ACTIVE"
      },
      "orderStatus" : "ONGOING",
      "orderProducts" : [ {
        "createdDateTime" : "2021-10-25T01:13:36.098919",
        "lastModifiedDateTime" : "2021-10-25T01:13:36.098919",
        "id" : 3,
        "product" : {
          "createdDateTime" : "2021-10-25T01:13:36.088929",
          "lastModifiedDateTime" : "2021-10-25T01:13:36.123861",
          "createdBy" : null,
          "lastModifiedBy" : null,
          "id" : 3,
          "name" : "panda",
          "description" : "nice bear",
          "productImage" : null,
          "price" : 50000,
          "stock" : 14500,
          "deletedDateTime" : null,
          "status" : "ACTIVE",
          "productCategory" : "MEAT",
          "region" : "CHUNGCHEONGBUKDO"
        },
        "quantity" : 500,
        "totalPrice" : 25000000
      } ],
      "delivery" : {
        "receiver" : "panda@naver.com",
        "address" : {
          "city" : "seoul",
          "street" : "yeonhui",
          "zipcode" : "01023"
        },
        "phone" : "01012345678"
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "https://localhost:8443/api/orders?memberId=3&page=0&size=10"
    }
  },
  "page" : {
    "size" : 10,
    "totalElements" : 1,
    "totalPages" : 1,
    "number" : 0
  }
}

주문 추가

Request

CURL

$ curl 'https://localhost:8443/api/orders' -i -X POST \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*' \
    -d '{
  "memberId" : 2,
  "productId" : 2,
  "quantity" : 30
}'

HTTPie

$ echo '{
  "memberId" : 2,
  "productId" : 2,
  "quantity" : 30
}' | http POST 'https://localhost:8443/api/orders' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request Fields

필드 타입 필수값 설명 제한

memberId

Number

true

회원 고유 번호

productId

Number

상품 고유 번호

quantity

Number

주문 수량

Request HTTP Example

POST /api/orders HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Content-Length: 58
Host: localhost:8443

{
  "memberId" : 2,
  "productId" : 2,
  "quantity" : 30
}

Response

Response HTTP Example

HTTP/1.1 201 Created
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN

주문 단건 삭제

Request

CURL

$ curl 'https://localhost:8443/api/orders' -i -X DELETE \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*' \
    -d '{
  "memberId" : 1,
  "orderId" : 1
}'

HTTPie

$ echo '{
  "memberId" : 1,
  "orderId" : 1
}' | http DELETE 'https://localhost:8443/api/orders' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request HTTP Example

DELETE /api/orders HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Content-Length: 37
Host: localhost:8443

{
  "memberId" : 1,
  "orderId" : 1
}

Response

Response HTTP Example

HTTP/1.1 204 No Content
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN

관리자 전용 주문 다건 조회

Request

CURL

$ curl 'https://localhost:8443/api/orders/admin' -i -X GET \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Accept: */*'

HTTPie

$ http GET 'https://localhost:8443/api/orders/admin' \
    'Content-Type:application/json;charset=UTF-8' \
    'Accept:*/*'

Request HTTP Example

GET /api/orders/admin HTTP/1.1
Content-Type: application/json;charset=UTF-8
Accept: */*
Host: localhost:8443

Response

Response Fields

필드 타입 필수값 설명 제한

_embedded.orderResponseList[].id

Number

true

주문 번호

_embedded.orderResponseList[].orderStatus

String

true

주문 상태

_embedded.orderResponseList[].orderProducts

Array

true

주문 상품 목록

_embedded.orderResponseList[].delivery

Object

true

배송 정보

_embedded.orderResponseList[].memberResponse

Object

true

주문 회원

_links

Object

true

HATEOAS

page

Object

true

페이지 설정

Response HTTP Example

HTTP/1.1 200 OK
Vary: Origin
Vary: Access-Control-Request-Method
Vary: Access-Control-Request-Headers
Content-Type: application/hal+json
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: SAMEORIGIN
Content-Length: 1900

{
  "_embedded" : {
    "orderResponseList" : [ {
      "id" : 1,
      "memberResponse" : {
        "id" : 4,
        "email" : "panda@naver.com",
        "nickname" : "panda",
        "profileImage" : null,
        "phone" : "01012345678",
        "license" : null,
        "createdDateTime" : "2021-10-25T01:13:36.266449",
        "lastModifiedDateTime" : "2021-10-25T01:13:36.266449",
        "leaveDateTime" : null,
        "authority" : null,
        "address" : {
          "city" : "seoul",
          "street" : "yeonhui",
          "zipcode" : "01023"
        },
        "authProvider" : null,
        "status" : "ACTIVE"
      },
      "orderStatus" : "ONGOING",
      "orderProducts" : [ {
        "createdDateTime" : "2021-10-25T01:13:36.282024",
        "lastModifiedDateTime" : "2021-10-25T01:13:36.282024",
        "id" : 4,
        "product" : {
          "createdDateTime" : "2021-10-25T01:13:36.271139",
          "lastModifiedDateTime" : "2021-10-25T01:13:36.514049",
          "createdBy" : null,
          "lastModifiedBy" : null,
          "id" : 4,
          "name" : "panda",
          "description" : "nice bear",
          "productImage" : null,
          "price" : 50000,
          "stock" : 14500,
          "deletedDateTime" : null,
          "status" : "ACTIVE",
          "productCategory" : "MEAT",
          "region" : "CHUNGCHEONGBUKDO"
        },
        "quantity" : 500,
        "totalPrice" : 25000000
      } ],
      "delivery" : {
        "receiver" : "panda@naver.com",
        "address" : {
          "city" : "seoul",
          "street" : "yeonhui",
          "zipcode" : "01023"
        },
        "phone" : "01012345678"
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "https://localhost:8443/api/orders/admin?page=0&size=10"
    }
  },
  "page" : {
    "size" : 10,
    "totalElements" : 1,
    "totalPages" : 1,
    "number" : 0
  }
}

'Project' 카테고리의 다른 글

product-api  (0) 2021.10.25
cart-api  (0) 2021.10.25
member-api  (0) 2021.10.25
5주차 Java-Spring 웹 개발 인강 후기  (0) 2021.09.07
4주차 Java-Spring 웹 개발 인강  (0) 2021.09.05
댓글
링크
글 보관함
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Total
Today
Yesterday