
๐ฏ ERD๋ฅผ ์ค๊ณํ๋ฉฐ API๋ฅผ ์์ ํฉ๋๋ค.
์ด์ ์์ฑํ๋ API๋ฅผ ์์ ํ๊ณ , ERD๋ฅผ ์์ฑํฉ๋๋ค.
๐ ์์ ํ ๋ถ๋ถ์ ์ฃผํฉ์ ๊ธ์จ๋ก ๋ํ๋ ๋๋ค.

Method : POST
URL : /join
HTTP Status Code : 201 Created
Request Body
{
"email": "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ด๋ฉ์ผ",
"password" : "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ๋น๋ฐ๋ฒํธ"
}
Method : POST
URL : /login
HTTP Status Code : 200 Ok
Request Body
{
"email": "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ด๋ฉ์ผ",
"password" : "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ๋น๋ฐ๋ฒํธ"
}
JWT TokenMethod : POST
URL : /rest
HTTP Status Code : 200 Ok
Request Body
{
"email": "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ด๋ฉ์ผ"
}
Method : PUT
URL : /rest
HTTP Status Code : 200 Ok
Request Body
{
"email": "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ด๋ฉ์ผ"
}

Method : GET
URL : /books
HTTP Status Code : 200 Ok
Request Body : x
Response Body :
[
{
"id" : ๋์ id,
"title": "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"author" : "๋์ ์๊ฐ",
"price" : ๊ฐ๊ฒฉ,
"likes" : ์ข์์ ์,
"pubDate" : "์ถ๊ฐ ๋ ์ง"
},
{
"id" : ๋์ id,
"title": "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"author" : "๋์ ์๊ฐ",
"price" : ๊ฐ๊ฒฉ,
"likes" : ์ข์์ ์,
"pubDate" : "์ถ๊ฐ ๋ ์ง"
},
...
]
TODO : ์ด๋ฏธ์ง ์ฃผ์ ์ ๋ฌ, ๋ฐ์ดํฐ๋ฅผ 8๊ฐ์ฉ ๋ณด๋ด์ฃผ์ด์ผ ํ๋ ๊ฒ์ ์ถํ์ ๊ณ ๋ํํ ์์ ์
๋๋ค.Method : GET
URL : /books/:id
HTTP Status Code : 200 Ok
Request Body
{
"email": "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ์ด๋ฉ์ผ",
"password" : "์ฌ์ฉ์๊ฐ ์
๋ ฅํ ๋น๋ฐ๋ฒํธ"
}
{
"id" : ๋์ id,
"title": "๋์ ์ ๋ชฉ",
"category" : "์นดํ
๊ณ ๋ฆฌ",
"format" : "ํฌ๋งท",
"isbn" : "isbn",
"summary" : "์์ฝ ์ค๋ช
",
"author" : "๋์ ์๊ฐ",
"pages" : ์ชฝ ์,
"index" : "๋ชฉ์ฐจ",
"price" : ๊ฐ๊ฒฉ,
"likes" : ์ข์์ ์,
"liked" : boolean,
"pubDate" : "์ถ๊ฐ ๋ ์ง"
}
TODO : ์ด๋ฏธ์ง ์ฃผ์ ์ ๋ฌ์ ์ถํ์ ๊ณ ๋ํํ ์์ ์
๋๋ค.Method : GET
URL : /books?categoryId=:categoryId&new={boolean}
HTTP Status Code : 200 Ok
Request Body : x
Response Body :
[
{
"id" : ๋์ id,
"title": "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"author" : "๋์ ์๊ฐ",
"price" : ๊ฐ๊ฒฉ,
"likes" : ์ข์์ ์,
"pubDate" : "์ถ๊ฐ ๋ ์ง"
},
{
"id" : ๋์ id,
"title": "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"author" : "๋์ ์๊ฐ",
"price" : ๊ฐ๊ฒฉ,
"likes" : ์ข์์ ์,
"pubDate" : "์ถ๊ฐ ๋ ์ง"
},
...
]
TODO : ์ด๋ฏธ์ง ์ฃผ์ ์ ๋ฌ, ๋ฐ์ดํฐ๋ฅผ 8๊ฐ์ฉ ๋ณด๋ด์ฃผ์ด์ผ ํ๋ ๊ฒ์ ์ถํ์ ๊ณ ๋ํํ ์์ ์
๋๋ค.
์ฐธ๊ณ ์ฌํญ : new๊ฐ true์ผ ๋ ์ ๊ฐ ์กฐํ ๊ธฐ์ค์ ์ถ๊ฐ์ผ๋ก๋ถํฐ 30์ผ ์ด๋ด

Method : POST
URL : /likes/:bookId
HTTP Status Code :200 Ok
Request Body : x
Response Body : x
Method : DELETE
URL : /likes/:bookId
HTTP Status Code : 200 Ok
Request Body : x
Response Body : x

Method : POST
URL : /cart
HTTP Status Code : 200 Ok
Request Body
{
"bookId" : ๋์ id,
"count" : ์๋
}
Method : GET
URL : /cart
HTTP Status Code : 200 Ok
Request Body : x
Response Body
[
{
"id" : ์ฅ๋ฐ๊ตฌ๋ id,
"bookId" : ๋์ id,
"title" : "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"count" : ์๋,
"price" : ๊ฐ๊ฒฉ
},
{
"id" : ์ฅ๋ฐ๊ตฌ๋ id,
"bookId" : ๋์ id,
"title" : "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"count" : ์๋,
"price" : ๊ฐ๊ฒฉ
},
]
Method : DELETE
URL : /cart/:cartItemId
HTTP Status Code : 200 Ok
Request Body : x
Response Body : x
Method : GET
URL : /์ถํ ๊ฒฐ์
HTTP Status Code : 200 Ok
Request Body
[ cartItemId, cartItemId, ... ]
[
{
"cartItemId" : ์ฅ๋ฐ๊ตฌ๋ id,
"bookId" : ๋์ id,
"title" : "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"count" : ์๋,
"price" : ๊ฐ๊ฒฉ
},
{
"cartItemId" : ์ฅ๋ฐ๊ตฌ๋ id,
"bookId" : ๋์ id,
"title" : "๋์ ์ ๋ชฉ",
"summary" : "์์ฝ ์ค๋ช
",
"count" : ์๋,
"price" : ๊ฐ๊ฒฉ
},
]
TODO : ์ถํ api ์์ 
Method : POST
URL : /orders
HTTP Status Code : 200 Ok
Request Body
{
"item": [
{
"cartItemId" : ์ฅ๋ฐ๊ตฌ๋ ๋์ id,
"bookId" : ๋์ id,
"count" : ์๋
},
{
"cartItemId" : ์ฅ๋ฐ๊ตฌ๋ ๋์ id,
"bookId" : ๋์ id,
"count" : ์๋
}
],
"delivery" : {
"address" : "์ฃผ์",
"receiver" : "์ด๋ฆ",
"contact" : "์ ํ๋ฒํธ"
},
"totalPrice" : ๊ธ์ก
}
Method : GET
URL : /orders
HTTP Status Code : 200 Ok
Request Body : x
Response Body :
[
{
"order_id" : ์ฃผ๋ฌธ id,
"created_at" : "์ฃผ๋ฌธ์ผ์",
"delivery" : {
"address" : "์ฃผ์",
"receiver" : "์ด๋ฆ",
"contact" : "์ ํ๋ฒํธ",
},
"bookTitle" : "๋ํ ์ฑ
์ ๋ชฉ",
"totalPrice" : ๊ฒฐ์ ๊ธ์ก,
"totalCount" : ์ด ์๋
},
{
"order_id" : ์ฃผ๋ฌธ id,
"created_at" : "์ฃผ๋ฌธ์ผ์",
"delivery" : {
"address" : "์ฃผ์",
"receiver" : "์ด๋ฆ",
"contact" : "์ ํ๋ฒํธ",
},
"bookTitle" : "๋ํ ์ฑ
์ ๋ชฉ",
"totalPrice" : ๊ฒฐ์ ๊ธ์ก,
"totalCount" : ์ด ์๋
},
...
]
Method : GET
URL : /orders/:id
HTTP Status Code : 200 Ok
Request Body : x
Response Body :
[
{
"bookId" : ๋์ id,
"bookTitle" : "๋์ ์ ๋ชฉ",
"author" : "์๊ฐ",
"price" : ๊ฐ๊ฒฉ,
"count" : ์๋
},
{
"bookId" : ๋์ id,
"bookTitle" : "๋์ ์ ๋ชฉ",
"author" : "์๊ฐ",
"price" : ๊ฐ๊ฒฉ,
"count" : ์๋
},
...
]

Table users {
id integer [primary key]
email varchar
password varchar
}
Table books {
id integar [primary key]
title varchar
category varchar
format varchar
isbn varchar
summary text
description text
author varchar
pages integer
index text
price integer
likes integer
pubDate timestamp
}
Table likes {
user_id integer
liked_book_id integer
}
Table cartItems {
id integer [primary key]
book_id integer
count integer
}
Table deliveries {
id integer [primary key]
address varchar
receiver varchar
contact varchar
}
Table orders {
id integer [primary key]
delivery_id integer
total_price integer
created_at timestamp
book_title varchar
total_count integer
}
Table orderedBook {
order_id integer
book_id integer
count integer
}
ref: orderedBook.order_id > orders.id
ref: orderedBook.book_id > books.id
ref: orders.delivery_id > deliveries.id
ref: cartItems.book_id > books.id
ref: likes.user_id > users.id
ref: likes.liked_book_id > books.id
ERD๋ฅผ ๊ฐ์ด ์ค๊ณํด๋ณด๋ ๋ฐ์ดํฐ ํ๋ฆ์ด ๋ ๋ช ํํด์ง๊ณ , API ์ค๊ณ ๋ฐฉํฅ๋ ํ๋์ ์ ๋ณด์ด๋ ๋๋์ด์์ต๋๋ค.