Skip to content

Commit

Permalink
BREAKING: 스프린트 미션 7 요구사항 완료
Browse files Browse the repository at this point in the history
  • Loading branch information
paengdal committed Dec 8, 2024
1 parent 00917b8 commit 9fee7f4
Show file tree
Hide file tree
Showing 11 changed files with 399 additions and 63 deletions.
33 changes: 33 additions & 0 deletions http/articles.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
###
POST http://localhost:3000/articles
Content-Type: application/json

{
"title":"갤럭시 S40",
"content":"쌈송에서 만든 최신 폰"
}

###
PATCH http://localhost:3000/articles/0456b46f-7a18-4211-b7a1-2216f84cc2cb
Content-Type: application/json

{
"content":"쌈송에서 만든 망폰"
}

###
GET http://localhost:3000/articles/0456b46f-7a18-4211-b7a1-2216f84cc2cb

###
GET http://localhost:3000/articles

###
POST http://localhost:3000/articles/0456b46f-7a18-4211-b7a1-2216f84cc2cb/comments
Content-Type: application/json

{
"content" : "이건 삭제할 댓글입니다."
}

###
DELETE http://localhost:3000/comments/cdd15137-d60a-4f58-8b71-398d802cdaa7
16 changes: 16 additions & 0 deletions http/comments.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

PATCH http://localhost:3000/comments/492cc17e-ae41-4156-9a33-748f76adb7c4
Content-Type: application/json

{
"content":"댓글 수정 테스트"
}

###
GET http://localhost:3000/products/comments

###
GET http://localhost:3000/products/comments?limit=3&cursor=8cbf2c41-8974-412e-8d43-98d4020a7217

###
GET http://localhost:3000/ariticles/comments
18 changes: 16 additions & 2 deletions requests.http → http/products.http
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ GET http://localhost:3000/products
GET http://localhost:3000/products?sort=recent&keyword=갤럭시

###
GET http://localhost:3000/products/0486722d-02f8-4a40-bdb0-0bfb2dfaeb70
GET http://localhost:3000/products/10f12b65-20f5-43d9-860e-faf4890e2a9e

###
POST http://localhost:3000/products
Expand All @@ -24,4 +24,18 @@ Content-Type: application/json
{
"name":"갤럭시 S50",
"price":5400
}
}

###
DELETE http://localhost:3000/products/b833f160-3ae9-4c23-94c5-f44fcdc73ccc

###

POST http://localhost:3000/products/10f12b65-20f5-43d9-860e-faf4890e2a9e/comments
Content-Type: application/json

{
"content" : "이게 가장 새로운 댓글"
}


29 changes: 0 additions & 29 deletions models/Product.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- You are about to drop the column `articleId` on the `Comment` table. All the data in the column will be lost.
*/
-- DropForeignKey
ALTER TABLE "Comment" DROP CONSTRAINT "Comment_articleId_fkey";

-- AlterTable
ALTER TABLE "Comment" DROP COLUMN "articleId";
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- Added the required column `articleId` to the `Comment` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Comment" ADD COLUMN "articleId" TEXT NOT NULL;

-- AddForeignKey
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_articleId_fkey" FOREIGN KEY ("articleId") REFERENCES "Article"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- Added the required column `productId` to the `Comment` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "Comment" ADD COLUMN "productId" TEXT NOT NULL;

-- AddForeignKey
ALTER TABLE "Comment" ADD CONSTRAINT "Comment_productId_fkey" FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "Comment" ALTER COLUMN "articleId" DROP NOT NULL,
ALTER COLUMN "productId" DROP NOT NULL;
15 changes: 9 additions & 6 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ datasource db {
// }

model Product {
id String @id @default(uuid())
id String @id @default(uuid())
name String
description String
price Int
tags String[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
comments Comment[]
}

model Article {
Expand All @@ -39,14 +40,16 @@ model Article {
updatedAt DateTime @updatedAt
// user User? @relation(fields: [userId], references: [id], onDelete: SetNull)
// userId String?
Comment Comment[]
comments Comment[]
}

model Comment {
id String @id @default(uuid())
content String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
article Article @relation(fields: [articleId], references: [id], onDelete: Cascade)
articleId String
article Article? @relation(fields: [articleId], references: [id], onDelete: Cascade)
articleId String?
product Product? @relation(fields: [productId], references: [id], onDelete: Cascade)
productId String?
}
Loading

0 comments on commit 9fee7f4

Please sign in to comment.