๊ณผ์ ๋ช
1. ์๊ตฌ์ฌํญ๋ถ์ / API์์ฒญ ๋ฐ ์๋ต ์๋๋ฆฌ์ค ๋ถ์
2. ์๊ตฌ์ฌํญ ์ถ๊ฐ ๋ฐ์ ๋ฐ ํ
์ด๋ธ ์ค๊ณ๋
๊ณผ์ ์ค๋ช
1. ์๊ตฌ์ฌํญ ์๋๋ฆฌ์ค๋ฅผ ๋ณด๊ณ ๋ถ์กฑํด ๋ณด์ด๋ ๊ธฐ๋ฅ์ ํ๋ ์ด์ ์ฒดํฌํ์ฌ README์ ๋ด์ฉ์ ์์ฑํ์์ค.
2. ์ ์๋ ํ๋ฉด์ค๊ณ๋ฅผ ๋ณด๊ณ ํด๋น ํ๋ฉด์ค๊ณ์ ๋ฐฐํฌ๋ ๊ธฐ์กด ์๋ฒ์ API์ฃผ์๋ฅผ ๋งค์นญํ์ฌ README์ ๋ด์ฉ์ ์์ฑํ์์ค. (์นด์นด์ค ํ๋ฉด์ค๊ณ ์๋๋ฆฌ์ค๊ฐ ์์)
3. ๋ฐฐํฌ๋ ์๋ฒ์ ๋ชจ๋ API๋ฅผ POSTMAN์ผ๋ก ์์ฒญํด๋ณธ ๋ค ์๋ต๋๋ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ๊ณ ๋ถ์กฑํ ๋ฐ์ดํฐ๊ฐ ๋ฌด์์ธ์ง ์ฒดํฌํ์ฌ README์ ๋ด์ฉ์ ์์ฑํ์์ค.
- API๋ ๋ฌด์์ผ๊น ? - https://codingdialee.tistory.com/35
- Response Body ํ์ธ
WEB | API ์์๋ณด๊ธฐ
00. API ? 1) API : ์ ํ๋ฆฌ์ผ์ด์ ์ํํธ์จ์ด๋ฅผ ๋น๋ํ๊ณ ํตํฉํ๊ธฐ ์ํ ์ ์ ๋ฐ ํ๋กํ ์ฝ ์ธํธ์ธ ์ ํ๋ฆฌ์ผ์ด์ ํ๋ก๊ทธ๋๋ฐ ์ธํฐํ์ด์ค(Application Programming Interface) - ํ๋ก๊ทธ๋จ๋ค์ด ์๋ก ์ํธ์์ฉํ๋
codingdialee.tistory.com
4. ํ ์ด๋ธ ์ค๊ณ๋ฅผ ํ์ฌ README์ ER-Diagram์ ์ถ๊ฐํ์ฌ ์ ์ถํ์์ค.
2. ์๊ตฌ์ฌํญ ์ถ๊ฐ ๋ฐ์ ๋ฐ ํ ์ด๋ธ ์ค๊ณ๋
03) ๋ฐฐํฌ๋ ์๋ฒ์ ๋ชจ๋ API๋ฅผ POSTMAN์ผ๋ก ์์ฒญํด๋ณธ ๋ค ์๋ต๋๋ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ๊ณ ๋ถ์กฑํ ๋ฐ์ดํฐ๊ฐ ๋ฌด์์ธ์ง ์ฒดํฌํ์ฌ README์ ๋ด์ฉ์ ์์ฑํ์์ค.
1. ์ ์ฒด ์ํ ๋ชฉ๋ก ์กฐํ
- API : http://localhost:8080/products
- Response body
{
"success": true,
"response": [
{
"id": 1,
"productName": "๊ธฐ๋ณธ์ ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค/ํ๋ผ์์๋์
์๋์
์ธ ์ฃผ๋ฐฉ์ฉํ ํน๊ฐ์ ",
"description": "",
"image": "/images/1.jpg",
"price": 1000
},
{
"id": 2,
"productName": "[ํฉ๊ธ์ฝ๋จ๋ฐค ๊ณจ๋]2022๋
์ฐ ํ๋ฐค ์นผ์ง๋ฐค700g์ธ/๊ตฐ๋ฐค์ฉ/์์จ",
"description": "",
"image": "/images/2.jpg",
"price": 2000
},
{
"id": 3,
"productName": "์ผ์ฑ์ ์ JBL JR310 ์ธ ์ด๋ฆฐ์ด์ฉ/์ฑ์ธ์ฉ ํค๋์
3์ข
!",
"description": "",
"image": "/images/3.jpg",
"price": 30000
},
{
"id": 4,
"productName": "๋ฐ๋ฅธ ๋๋ฃฝ์ง๋ง ๋ฐํจํจ์ 2๋ฐ์ค ์ญ๊ฐ์์น๋ณด์ฅ / ์ธ 7์ข
",
"description": "",
"image": "/images/4.jpg",
"price": 4000
},
{
"id": 5,
"productName": "[๋์ฃผ] ์ปทํ
๋ง๋์ฅ์กฑ, ์๋ค๋ฆฌ 100g/300g ์ธ ์ฃผ์ ๋ถ๋ฆฌ ๋ชจ์ /์ค๋
์ฑ ์ต๊ณ /๋ง๋ฅธ์์ฃผ",
"description": "",
"image": "/images/5.jpg",
"price": 5000
},
{
"id": 6,
"productName": "๊ตณ์ง์๋ ์๊ธ์ ํธ 1,050g 2ํฉ ์ธ ์ฐ๋ฆฌ์๋ก ๋ชจ์์ ",
"description": "",
"image": "/images/6.jpg",
"price": 15900
},
{
"id": 7,
"productName": "eoe ์ด๋๋๋ฆฌํฐ 30ํฌ, ์ค๋ ์ง๋ง ๊ณ ์์ด์ฌ์ ๋ณด์ถฉ์ ",
"description": "",
"image": "/images/7.jpg",
"price": 26800
},
{
"id": 8,
"productName": "์ ๋๋ฒจ PDRN ํฌ๋ฆผ 2๊ฐ. ํผ๋ถ๋ณด์ต/์ง์ ์ผ์ด",
"description": "",
"image": "/images/8.jpg",
"price": 25900
},
{
"id": 9,
"productName": "ํ๋ ์ด์คํ
์ด์
VR2 ํธ๋ผ์ด์ฆ ๋ฒ๋ค. ์์ํ ๋ชฐ์
๊ฐ",
"description": "",
"image": "/images/9.jpg",
"price": 797000
}
],
"error": null
}
- ์ถ๊ฐํ ๋งํ ๋ฐ์ดํฐ
> ๊ฐ์์์ ์ธ๊ธํ์ ๊ฒ๊ณผ ๊ฐ์ด ๋ณ์ ๊ธฐ๋ฅ์ ์ถ๊ฐํ๋ค๋ฉด, ๋ณ์ ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํด์ผ ํ ๊ฒ ๊ฐ๋ค.
2. ๊ฐ๋ณ ์ํ ์์ธ ์กฐํ
- API : http://localhost:8080/products/1
- Response Body
{
"success": true,
"response": {
"id": 1,
"productName": "๊ธฐ๋ณธ์ ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค/ํ๋ผ์์๋์
์๋์
์ธ ์ฃผ๋ฐฉ์ฉํ ํน๊ฐ์ ",
"description": "",
"image": "/images/1.jpg",
"price": 1000,
"starCount": 5,
"options": [
{
"id": 1,
"optionName": "01. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค์๋์
4์ข
",
"price": 10000
},
{
"id": 2,
"optionName": "02. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํ๋ผ์์๋์
5์ข
",
"price": 10900
},
{
"id": 3,
"optionName": "๊ณ ๋ฌด์ฅ๊ฐ ๋ฒ ์ด์ง S(์ํ) 6ํฉ",
"price": 9900
},
{
"id": 4,
"optionName": "๋ฝ์์ฐ๋ ํค์นํ์ฌ 130๋งค 12ํฉ",
"price": 16900
},
{
"id": 5,
"optionName": "2๊ฒน ์๋นต์์ธ๋ฏธ 6๋งค",
"price": 8900
}
]
},
"error": null
}
- ์ถ๊ฐํ ๋งํ ๋ฐ์ดํฐ
- ์ ํ ์์ธ ์ ๋ณด ์ค๋ช ๋ฐ์ดํฐ
- ๋ณ์ or ๋ฆฌ๋ทฐ ๋ฐ์ดํฐ
- ๋ฐฐ์ก๋น
3. ์ด๋ฉ์ผ ์ค๋ณต ์ฒดํฌ
- API : http://localhost:8080/check
- Response body
{
"success": false,
"response": null,
"error": {
"message": "์ด๋ฉ์ผ ํ์์ผ๋ก ์์ฑํด์ฃผ์ธ์:email",
"status": 400
}
}
- ์ถ๊ฐ ๋ฐ์ดํฐ x
4. ํ์๊ฐ์
- API : http://localhost:8080/join
- ํ์๊ฐ์ ์ฑ๊ณต ์ Response body
{
"success": true,
"response": null,
"error": null
}
- ํ์๊ฐ์ ์คํจ ์ Response body
{
"success": false,
"response": null,
"error": {
"message": "8์์ 20์ ์ด๋ด์ฌ์ผ ํฉ๋๋ค.:password",
"status": 400
}
}
- ์ถ๊ฐ ๋ฐ์ดํฐ x
5. ๋ก๊ทธ์ธ
- API : http://localhost:8080/login
- Response body
{
"success": true,
"response": null,
"error": null
}
- ์ถ๊ฐ ๋ฐ์ดํฐ x
6. ์ฅ๋ฐ๊ตฌ๋ ๋ด๊ธฐ
- API : http://localhost:8080/carts/add
- Response body
{
"success": true,
"response": null,
"error": null
}
- ๋ฐฐ์ก๋น๊ฐ ์๋ค๋ฉด ๋ฐฐ์ก๋น ๋ฐ์ดํฐ ?
7. ์ฅ๋ฐ๊ตฌ๋ ์กฐํ
- API : http://localhost:8080/carts
- Response body
{
"success": true,
"response": {
"products": [
{
"id": 1,
"productName": "๊ธฐ๋ณธ์ ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค/ํ๋ผ์์๋์
์๋์
์ธ ์ฃผ๋ฐฉ์ฉํ ํน๊ฐ์ ",
"carts": [
{
"id": 4,
"option": {
"id": 1,
"optionName": "01. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค์๋์
4์ข
",
"price": 10000
},
"quantity": 5,
"price": 50000
},
{
"id": 5,
"option": {
"id": 2,
"optionName": "02. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํ๋ผ์์๋์
5์ข
",
"price": 10900
},
"quantity": 5,
"price": 54500
}
]
}
],
"totalPrice": 104500
},
"error": null
}
- ์ฅ๋ฐ๊ตฌ๋ ์ต์ ์ญ์ ๊ธฐ๋ฅ
- ์ต๊ทผ ๋ณธ ์ํ ๋ฐ์ดํฐ or ์ฐ๊ด์๋ ์ํ ๋ฐ์ดํฐ
8. ์ฃผ๋ฌธํ๊ธฐ - ์ฅ๋ฐ๊ตฌ๋ ์์
- API : http://localhost:8080/carts/update
- Response body
{
"success": true,
"response": {
"carts": [
{
"cartId": 4,
"optionId": 1,
"optionName": "01. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค์๋์
4์ข
",
"quantity": 10,
"price": 100000
},
{
"cartId": 5,
"optionId": 2,
"optionName": "02. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํ๋ผ์์๋์
5์ข
",
"quantity": 10,
"price": 109000
}
],
"totalPrice": 209000
},
"error": null
}
- ์ฅ๋ฐ๊ตฌ๋ ์ต์ ์ญ์ ๊ธฐ๋ฅ
- ์ต๊ทผ ๋ณธ ์ํ ๋ฐ์ดํฐ or ์ฐ๊ด์๋ ์ํ ๋ฐ์ดํฐ
9. ๊ฒฐ์ ํ๊ธฐ - ์ฃผ๋ฌธ ์ธ์ํธ
- API : http://localhost:8080/orders/save
- Response body
{
"success": true,
"response": {
"id": 2,
"products": [
{
"productName": "๊ธฐ๋ณธ์ ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค/ํ๋ผ์์๋์
์๋์
์ธ ์ฃผ๋ฐฉ์ฉํ ํน๊ฐ์ ",
"items": [
{
"id": 4,
"optionName": "01. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค์๋์
4์ข
",
"quantity": 10,
"price": 100000
},
{
"id": 5,
"optionName": "02. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํ๋ผ์์๋์
5์ข
",
"quantity": 10,
"price": 109000
}
]
}
],
"totalPrice": 209000
},
"error": null
}
- ๋ฐฐ์ก๋น ์๋ค๋ฉด ๋ฐฐ์ก๋น ํฉ๊ณ ๋ฐ์ดํฐ
10. ์ฃผ๋ฌธ ๊ฒฐ๊ณผ ํ์ธ
- API : http://localhost:8080/orders/1
- Response body
{
"success": true,
"response": {
"id": 2,
"products": [
{
"productName": "๊ธฐ๋ณธ์ ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค/ํ๋ผ์์๋์
์๋์
์ธ ์ฃผ๋ฐฉ์ฉํ ํน๊ฐ์ ",
"items": [
{
"id": 4,
"optionName": "01. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํฌ๋ฆฌ์ค๋ง์ค์๋์
4์ข
",
"quantity": 10,
"price": 100000
},
{
"id": 5,
"optionName": "02. ์ฌ๋ผ์ด๋ฉ ์งํผ๋ฐฑ ํ๋ผ์์๋์
5์ข
",
"quantity": 10,
"price": 109000
}
]
}
],
"totalPrice": 209000
},
"error": null
}
- ์ฃผ๋ฌธ ๋ฒํธ ๋ฐ์ดํฐ
'๐ช kakaotech campus' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์นดํ ์ผ | [STEP2 clone coding] 2์ฃผ์ฐจ ๊ณผ์ - (1) (0) | 2023.07.04 |
---|---|
์นดํ ์ผ | [STEP2 clone coding] 1์ฃผ์ฐจ ๊ณผ์ - (3) (0) | 2023.06.30 |
์นดํ ์ผ | [STEP2 clone coding] 1์ฃผ์ฐจ ๊ณผ์ - (1) (0) | 2023.06.28 |
์นดํ ์ผ | ์นด์นด์คํก ์ผํํ๊ธฐ ํด๋ก ํ๋ก์ ํธ ๊ณผ์ ๐ (0) | 2023.06.27 |
์นดํ ์ผ | ๐ ์นด์นด์คํ ํฌ ์บ ํผ์ค 1๋จ๊ณ ์๋ฃ ํ๊ธฐ (0) | 2023.06.17 |