# 키오스크 API 명세
## GET /api/categories
전체 카테고리와 카테고리에 해당하는 메뉴 목록을 가져옵니다. 메뉴 목록은 당일 판매량을 기준으로 내림차순으로 정렬됩니다.
**Response Example**
🟢 200: OK
```json
{
"result": [
{
"id": 1,
"name": "커피",
"menu": [
{
"id": 2,
"name": "콜드브루",
"imgUrl": "",
"price": 5000,
"todaySellCount": 2
},
{
"id": 1,
"name": "아메리카노",
"imgUrl": "",
"price": 4000,
"todaySellCount": 0
}
]
}
]
}
```
---
## GET /api/item/:id
옵션 정보를 포함한 상품의 상세 정보를 가져옵니다.
**Path Parameters**
| Name | Data Type | Description |
| ---- | ------ | ----------- |
| id | number | 상품 ID |
**Response Example**
🟢 200: OK
```json
{
"result": {
"id": 2,
"name": "콜드브루",
"imgUrl": "",
"price": 5000,
"todaySellCount": 2,
"options": [
{
"id": 1,
"name": "크기",
"details": [
{
"id": 1,
"name": "작은 것",
"price": 0
},
{
"id": 2,
"name": "큰 것",
"price": 500
}
]
}
]
}
}
```
---
## POST /api/item
상품을 추가합니다. 같은 이름의 상품이 이미 존재한다면 에러 메시지를 반환합니다.
**Request Body Example** (application/json)
```json
{
"name": "에스프레소",
"categoryId": 1,
"imgUrl": "",
"price": 5000,
"optionIds": [1]
}
```
**Response Example**
🟢 201: Created
```json
{
"message": "상품 추가를 성공적으로 완료했습니다.",
"result": {
"id": 3,
"name": "에스프레소",
"imgUrl": "",
"price": 5000,
"todaySellCount": 0,
"options": [
{
"id": 1,
"name": "크기",
"detail": [
{
"id": 1,
"name": "작은 것",
"price": 0
},
{
"id": 2,
"name": "큰 것",
"price": 500
}
]
}
]
}
}
```
🔴 409: Conflict
```json
{
"statusCode": 409,
"message": "동일한 이름의 상품이 이미 존재합니다."
}
```
---
## PUT /api/item/:id
상품을 정보를 업데이트합니다.
**Path Parameters**
| Name | Data Type | Description |
| ---- | ------ | ----------- |
| id | number | 상품 ID |
**Request Body Example** (application/json)
```json
{
"name": "에스프레소",
"categoryId": 1,
"imgUrl": "",
"price": 6000,
"optionIds": [2]
}
```
**Response Example**
🟢 201: Created
```json
{
"message": "상품 수정을 성공적으로 완료했습니다.",
"result": {
"id": 3,
"name": "에스프레소",
"imgUrl": "",
"price": 6000,
"todaySellCount": 0,
"options": [
{
"id": 2,
"name": "온도",
"detail": [
{
"id": 3,
"name": "HOT",
"price": 0
},
{
"id": 4,
"name": "ICE",
"price": 9
}
]
}
]
}
}
```
---
## DELETE /api/item/:id
상품을 삭제합니다.
**Path Parameters**
| Name | Data Type | Description |
| ---- | ------ | ----------- |
| id | number | 상품 ID |
**Response Example**
🟢 201: Created
```json
{
"message": "상품 삭제를 성공적으로 완료했습니다."
}
```
---
## GET /api/options
모든 옵션을 가져옵니다.
**Response Example**
🟢 200: OK
```json
{
"result": [
{
"id": 1,
"name": "크기",
"detail": [
{
"id": 1,
"name": "작은 것",
"price": 0
},
{
"id": 2,
"name": "큰 것",
"price": 500
}
]
},
{
"id": 2,
"name": "온도",
"detail": [
{
"id": 3,
"name": "HOT",
"price": 0
},
{
"id": 4,
"name": "ICE",
"price": 9
}
]
}
]
}
```
---
## GET /api/orders
모든 거래 내역을 가져옵니다. 날짜를 쿼리 파라미터로 넘기면 해당 날짜의 거래 내역만 가져옵니다.
**Query Parameters**
| Name | Data Type | Description |
| ---- | ------ | ----------- |
| date(optional) | Date | 해당 날짜 |
**Response Example**
🟢 201: Created
```json
{
"result": [
{
"id": 1,
"orderNumber": 1,
"createdAt": "2022-08-05T20:12:18.973Z",
"paymentMethod": "현금",
"totalPrice": 10000,
"detail": [
{
"id": 1,
"menuName": "아메리카노",
"count": 2,
"totalPrice": 5000,
"options": [
{
"id": 1,
"name": "크기 큰 것",
"price": 500,
"count": 1
}
]
}
]
}
]
}
```
---
## POST /api/orders
주문 내역을 DB에 저장하고, 현재 주문 번호를 반환합니다.
**Request Body Example** (application/json)
```json
{
"paymentMethod": "현금",
"menu": [
{
"id": 1,
"count": 2,
"optionDetail": [
{
"id": 1,
"count": 2
}
]
}
]
}
```
**Response Example**
🟢 201: Created
```json
{
"message": "주문을 성공적으로 완료했습니다.",
"result": {
"id": 2,
"orderNumber": 2,
"createdAt": "2022-08-06T20:12:18.973Z",
"paymentMethod": "카드",
"totalPrice": 10000,
"detail": [
{
"id": 1,
"menuName": "아메리카노",
"count": 2,
"totalPrice": 5000,
"options": [
{
"id": 1,
"name": "크기 큰 것",
"price": 500,
"count": 1
}
]
}
]
}
}
```