From 5fff7d4232f511be2fb63b3e6e16f93befb68451 Mon Sep 17 00:00:00 2001 From: sehwanii Date: Mon, 13 Jan 2025 00:51:00 +0900 Subject: [PATCH 1/6] Update README.md --- README.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/README.md b/README.md index 48bc43c..3bf9498 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,36 @@ # Hrr_BE Hrr_BE + +# Project Name + +## Table of Contents +1. [Introduction](#introduction) +2. [Conventions](#conventions) +3. [Deployed API Service](#deployed-api-service) +4. [API Documentation](#api-documentation) +5. [Getting Started](#getting-started) + +--- + +## Introduction +Briefly describe your project, its purpose, and key features. + +--- + +## Conventions +- For code conventions and guidelines, please refer to [rules.md](./rules.md). + +--- + +## Deployed API Service +- **Service Address:** `13.124.126.83:3000` + +--- + +## API Documentation +- Swagger Documentation: [13.124.126.83:3000/docs](http://13.124.126.83:3000/docs) + +--- + +## Getting Started +Provide steps to set up the project locally, prerequisites, and how to contribute. From 4eb445c5dffbcd2ef5a6fecfc1c8fa01da6b8ac8 Mon Sep 17 00:00:00 2001 From: sehwanii Date: Mon, 13 Jan 2025 00:52:02 +0900 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3bf9498..1838682 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Briefly describe your project, its purpose, and key features. --- ## Conventions -- For code conventions and guidelines, please refer to [rules.md](./rules.md). +- For code conventions and guidelines, please refer to [[rules.md](https://github.com/Hrr-HabbitRoutineResult/Hrr_BE/blob/main/Rules.md)] --- From 3e8c1aaeb6bde3b6e83621637e02fa30a10653e7 Mon Sep 17 00:00:00 2001 From: Minkyung02 Date: Tue, 14 Jan 2025 21:01:55 +0900 Subject: [PATCH 3/6] Feat: modify-database Fix --- prisma/schema.prisma | 147 +++++++++++++++++++++++++++++- prisma/seed.js | 208 ------------------------------------------- prisma/seed.sql | 154 ++++++++++++++++++++++++++++++++ 3 files changed, 297 insertions(+), 212 deletions(-) delete mode 100644 prisma/seed.js create mode 100644 prisma/seed.sql diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 43bca8d..c60fcf2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -22,7 +22,7 @@ model User { userBadge3 UserBadge? @relation("Badge3", fields: [userBadge3_id], references: [id]) userBadge3_id Int name String @db.VarChar(10) - gender String @db.VarChar(255) + gender Gender? email String @db.VarChar(255) phoneNumber String @db.VarChar(15) password String @db.VarChar(255) @@ -30,10 +30,15 @@ model User { updated_at DateTime @db.DateTime(6) inactiveDate DateTime @db.DateTime(6) profilePhoto String? @db.VarChar(255) - level Int + level Level? followerCount Int followingCount Int points Int + job Job? + userCategory UserCategory? + ageGroup AgeGroup? + + challengeLikes ChallengeLike[] comments Comment[] @@ -46,6 +51,8 @@ model User { temporaryVerifications TemporaryVerification[] challenges Challenge[] userChallenges UserChallenge[] + userGoals UserGoal[] + alarm Alarm[] followers Follow[] @relation("FollowerRelation") followings Follow[] @relation("FollowingRelation") @@ -158,6 +165,7 @@ model Verification { verificationStatus VerificationStatus @map("status") created_at DateTime? @db.DateTime(6) updated_at DateTime? @db.DateTime(6) + deadline DateTime? @db.DateTime(6) comments Comment[] temporaryVerifications TemporaryVerification[] @@ -184,7 +192,10 @@ model Follow { follower_id Int following User @relation("FollowingRelation", fields: [following_id], references: [id]) following_id Int + + alarms Alarm[] @relation("SenderAlarm") + @@unique([follower_id, following_id]) @@map("Follows") } @@ -193,8 +204,12 @@ model Badge { name String? @db.VarChar(50) icon String? @db.VarChar(255) description String? @db.Text + type BadgeType? + obtainedCount Int? + profileImage String? @db.VarChar(255) userBadges UserBadge[] + conditions Condition[] @@map("Badges") } @@ -206,10 +221,13 @@ model UserBadge { badge Badge @relation(fields: [badge_id], references: [id]) badge_id Int created_at DateTime? @db.DateTime(6) + obtain Boolean + updated_at DateTime? @db.DateTime(6) userBadge1 User[] @relation("Badge1") userBadge2 User[] @relation("Badge2") userBadge3 User[] @relation("Badge3") + userBadgeCondtions UserBadgeCondition[] @@map("User_Badge") } @@ -233,7 +251,7 @@ model FavorType { } model UserCategoryType { - id Int + id Int user User @relation(fields: [user_id], references: [id]) user_id Int category Category @relation(fields: [category_id], references: [id]) @@ -342,7 +360,7 @@ model UserChallenge { verifyCount Int? unverifiedCount Int? userChallengeStatus UserChallengeStatus @map("status") - warn Int? + warn Int @default(0) verification Verification[] kickOuts KickOut[] @@ -361,6 +379,86 @@ model ChallengeKeyword { @@map("Challenge_Keyword") } +model Goal { + id Int @id @default(autoincrement()) + name Name + + userGoals UserGoal[] + + @@map("Goals") +} + +model UserGoal { + user_id Int + goal_id Int + + user User @relation(fields: [user_id], references: [id], onDelete: Cascade) + goal Goal @relation(fields: [goal_id], references: [id], onDelete: Cascade) + + @@id([user_id, goal_id]) + @@map("User_Goal") +} + +model Alarm { + id Int @id @default(autoincrement()) + user User @relation(fields: [user_id], references: [id]) + user_id Int + sender Follow? @relation("SenderAlarm", fields: [sender_id], references: [id]) + sender_id Int? + alarmType AlarmType + referenceId Int @map("reference_id") + message String? @db.VarChar(200) + isRead Boolean? + created_at DateTime @default(now()) + + @@map("Alarms") +} + +model Condition { + id Int @id @default(autoincrement()) + badge Badge @relation(fields: [badge_id], references: [id]) + badge_id Int + description String? + + userBadgeConditions UserBadgeCondition[] + + @@map("Conditions") +} + +model UserBadgeCondition { + id Int @id @default(autoincrement()) + userBadge UserBadge @relation(fields: [userBadge_id], references: [id]) + userBadge_id Int + condition Condition @relation(fields: [condition_id], references: [id]) + condition_id Int + isAchieved Boolean? + + @@map("User_Badge_Condition") +} + +enum AlarmType { + follow + verificationComment + postComment + warning + kickOut + newVerification + deadline +} + +enum Name { + health + diet + foodControl + smallGoal + studyTogether + makeHabit + studyRoutine + buildCapacity + escape_3 + qualification +} + enum BoardStatus { basic pinned @@ -403,3 +501,44 @@ enum UserChallengeStatus { active } +enum Level { + bronze + silver + gold + master + challenger +} + +enum Gender { + male + female +} + +enum Job { + middleHighSchoolStudent + collegeStudent + jobSeeker + officeWorker + housewife +} + +enum AgeGroup { + teen @map("10s") + twenty @map("20s") + thirty @map("30s") + forty @map("40s") + fiftyUp @map("50s+") +} + +enum UserCategory { + exercise + study + hobby + jobPreparation + lifestyle +} + +enum BadgeType { + category + type +} \ No newline at end of file diff --git a/prisma/seed.js b/prisma/seed.js deleted file mode 100644 index d524c95..0000000 --- a/prisma/seed.js +++ /dev/null @@ -1,208 +0,0 @@ -import { PrismaClient } from '@prisma/client'; - -const prisma = new PrismaClient(); - -async function main() { - // 1. Create Keywords - const keyword1 = await prisma.keyword.create({ data: { name: 'Health' } }); - const keyword2 = await prisma.keyword.create({ data: { name: 'Fitness' } }); - - // 2. Create Categories - const category1 = await prisma.category.create({ data: { name: 'Education' } }); - const category2 = await prisma.category.create({ data: { name: 'Wellness' } }); - - // 3. Create Badges - const badge1 = await prisma.badge.create({ - data: { name: 'Achiever', icon: '๐Ÿ†', description: 'Completed 10 challenges' }, - }); - const badge2 = await prisma.badge.create({ - data: { name: 'Beginner', icon: '๐Ÿ”ฐ', description: 'First Challenge Joined' }, - }); - - // 4. Create Users - const user1 = await prisma.user.create({ - data: { - name: 'Alice', - gender: 'Female', - email: 'alice@example.com', - phoneNumber: '1234567890', - password: 'securepassword', - created_at: new Date(), - updated_at: new Date(), - inactiveDate: new Date(), - profilePhoto: 'https://example.com/photo.jpg', - level: 1, - followerCount: 100, - followingCount: 50, - points: 1500, - }, - }); - - const user2 = await prisma.user.create({ - data: { - name: 'Bob', - gender: 'Male', - email: 'bob@example.com', - phoneNumber: '9876543210', - password: 'securepassword', - created_at: new Date(), - updated_at: new Date(), - inactiveDate: new Date(), - profilePhoto: 'https://example.com/photo2.jpg', - level: 2, - followerCount: 200, - followingCount: 100, - points: 3000, - }, - }); - - // 5. Create UserBadges - await prisma.userBadge.create({ - data: { user_id: user1.id, badge_id: badge1.id, created_at: new Date() }, - }); - - // 6. Create Boards - const board = await prisma.board.create({ - data: { - name: 'Announcements', - description: 'General announcements for everyone', - boardStatus: 'pinned', - }, - }); - - // 7. Create Posts - const post1 = await prisma.post.create({ - data: { - user_id: user1.id, - board_id: board.id, - title: 'Welcome to the Board!', - content: 'Feel free to share your thoughts here.', - anonymous: false, - created_at: new Date(), - updated_at: new Date(), - }, - }); - - // 8. Create Comments - await prisma.comment.create({ - data: { - user_id: user2.id, - post_id: post1.id, - verification_id: 1, - content: 'Thank you for creating this board!', - created_at: new Date(), - updated_at: new Date(), - }, - }); - - // 9. Create PostLikes - await prisma.postLike.create({ data: { user_id: user2.id, post_id: post1.id } }); - - // 10. Create Follows - await prisma.follow.create({ data: { follower_id: user1.id, following_id: user2.id } }); - - // 11. Create Messages - await prisma.message.create({ - data: { - sendUser_id: user1.id, - receivedUser_id: user2.id, - content: 'Hello Bob!', - created_at: new Date(), - }, - }); - - // 12. Create Challenges - const challenge = await prisma.challenge.create({ - data: { - owner_id: user1.id, - name: '30-Day Fitness', - type: 'basic', - description: 'Join this challenge to stay fit.', - challengeImage: 'https://example.com/image.jpg', - challengeStatus: 'open', - maxParticipants: 100, - verificationType: 'camera', - rule: 'Post a photo every day.', - created_at: new Date(), - updated_at: new Date(), - }, - }); - - // 13. Create ChallengeLikes - await prisma.challengeLike.create({ data: { user_id: user2.id, challenge_id: challenge.id } }); - - // 14. Create Frequencies - await prisma.frequency.create({ - data: { - challenge_id: challenge.id, - frequencyType: 'weeklyCount', - frequencyValue: { count: 3 }, - }, - }); - - // 15. Create UserChallenges - const userChallenge = await prisma.userChallenge.create({ - data: { - challenge_id: challenge.id, - user_id: user1.id, - challengeStatus: 'open', - joinDate: new Date(), - endDate: null, - verifyCount: 0, - unverifiedCount: 0, - userChallengeStatus: 'active', - warn: 0, - }, - }); - - // 16. Create Verifications - await prisma.verification.create({ - data: { - user_id: user1.id, - userChallenge_id: userChallenge.id, - challengeType: 'basic', - verificationType: 'camera', - photoUrl: 'https://example.com/verification.jpg', - title: 'Day 1 Proof', - content: 'Here is my workout photo for day 1.', - verificationStatus: 'verified', - created_at: new Date(), - updated_at: new Date(), - }, - }); - - // 17. Create Scraps - await prisma.scrap.create({ - data: { - user_id: user1.id, - scrapTarget1_id: 1, - scrapTarget2_id: 234, - scrapType: 'verification', - created_at: new Date(), - }, - }); - - // 18. Create TemporaryVerifications - await prisma.temporaryVerification.create({ - data: { - user_id: user2.id, - verification_id: 1, - challengeType: 'basic', - title: 'Temporary Proof', - content: 'Temporary content example', - created_at: new Date(), - updated_at: new Date(), - }, - }); - - console.log('๐ŸŒฑ Database has been seeded.'); -} - -main() - .catch(e => { - console.error(e); - process.exit(1); - }) - .finally(async () => { - await prisma.$disconnect(); - }); diff --git a/prisma/seed.sql b/prisma/seed.sql new file mode 100644 index 0000000..1472569 --- /dev/null +++ b/prisma/seed.sql @@ -0,0 +1,154 @@ +--Users Table +INSERT INTO Users (name, gender, email, phoneNumber, password, created_at, updated_at, inactiveDate, profilePhoto, level, followerCount, followingCount, points, job, userCategory, ageGroup) VALUES +('John Doe', 'male', 'john@example.com', '1234567890', 'password123', NOW(), NOW(), NULL, 'https://example.com/profile1.jpg', 'bronze', 10, 5, 100, 'officeWorker', 'exercise', 'twenty'), +('Jane Smith', 'female', 'jane@example.com', '0987654321', 'password456', NOW(), NOW(), NULL, 'https://example.com/profile2.jpg', 'silver', 20, 15, 200, 'collegeStudent', 'study', 'thirty'); + +--Keywords Table +INSERT INTO Keywords (name) VALUES +('motivation'), +('study'), +('health'), +('productivity'); + +--Badges Table +INSERT INTO Badges (name, icon, description, type, obtainedCount, profileImage) VALUES +('Starter Badge', 'https://example.com/badge1.png', 'Awarded for starting your first challenge', 'category', 100, 'https://example.com/badge1_profile.png'), +('Achiever Badge', 'https://example.com/badge2.png', 'Awarded for completing 5 challenges', 'type', 50, 'https://example.com/badge2_profile.png'); + +--Challenges Table +INSERT INTO Challenges (owner_id, name, type, description, challengeImage, status, maxParticipants, verificationType, rule, created_at, updated_at) VALUES +(1, '๋งค์ผ ์šด๋™', 'basic', 'A challenge to exercise daily for 30 minutes', 'https://example.com/challenge1.png', 'open', 50, 'camera', 'Submit a photo after exercise', NOW(), NOW()), +(2, '๊ฐ™์ด ๊ณต๋ถ€', 'study', 'Study 2 hours every day for a week', 'https://example.com/challenge2.png', 'ongoing', 30, 'text', 'Submit a text summary of what you studied', NOW(), NOW()); + +--Posts Table +INSERT INTO Posts (user_id, board_id, title, content, anonymous, created_at, updated_at) VALUES +(1, 1, 'My First Post', 'Excited to join this community!', FALSE, NOW(), NOW()), +(2, 1, 'Study Tips', 'Sharing my tips for effective studying.', TRUE, NOW(), NOW()); + +--Comments Table +INSERT INTO Comments (user_id, post_id, verification_id, content, created_at, updated_at) VALUES +(1, 3, 5,'Welcome to the community!', NOW(), NOW()), +(2, 4, 6,'Thanks for the tips!', NOW(), NOW()); + +--Follows Table +INSERT INTO Follows (follower_id, following_id) VALUES +(1, 2), +(2, 1); + +--User Badges Table +INSERT INTO User_Badge (user_id, badge_id, created_at, obtain, updated_at) VALUES +(1, 1, NOW(), TRUE, NOW()), +(2, 2, NOW(), TRUE, NOW()); + +--User Goals Table +INSERT INTO User_Goal (user_id, goal_id) VALUES +(1, 1), +(2, 2); + +--Alarms Table +INSERT INTO Alarms (user_id, sender_id, alarmType, referenceId, message, isRead, created_at) VALUES +(1, NULL, 'follow', 1, 'You have a new follower!', FALSE, NOW()), +(2, NULL, 'verificationComment', 1, 'Your verification has a new comment!', FALSE, NOW()); + +-- Challenge Likes Table +INSERT INTO ChallengeLikes (challenge_id, user_id) VALUES +(1, 1), +(2, 2); + +-- Post Likes Table +INSERT INTO PostLikes (post_id, user_id) VALUES +(3, 1), +(4, 2); + +-- Messages Table +INSERT INTO Messages (sendUser_id, receivedUser_id, content, created_at) VALUES +(1, 2, 'Hello, how are you?', NOW()), +(2, 1, 'I am fine, thank you!', NOW()); + +-- Verifications Table +INSERT INTO Verifications (userChallenge_id, user_id, status, created_at, updated_at) VALUES +(3, 1, 'verified', NOW(), NOW()), +(4, 2, 'unverified', NOW(), NOW()); + +-- Category Table +INSERT INTO Category (name) VALUES +('์šด๋™'), +('ํ•™์—…'), +( '์ทจ์—…์ค€๋น„'), +( '์ƒํ™œ์Šต๊ด€'), +( '์ทจ๋ฏธ'); + + +-- Favor Type Table +INSERT INTO FavorType (name) VALUES +( '๋ฒ ์ด์ง'), +( '์Šคํ„ฐ๋””'); + +-- User Category Type Table +INSERT INTO User_CategoryType (user_id, category_id) VALUES +(1, 1), +(2, 2); + +-- User Challenge Table +INSERT INTO User_Challenge (user_id, challenge_id, status) VALUES +(1, 1, 'active'), +(2, 2, 'kick'); + +-- Goals Table +INSERT INTO Goals (name) VALUES +('foodControl'), +('smallGoal'), +('studyTogether'), +('buildCapacity'), +('escape_3'), +('qualification'); + +-- Conditions Table +INSERT INTO Conditions (badge_id, description) VALUES +(1, 'Exercise daily for 30 minutes'), +(2, 'Study 2 hours every day'); + +--User Badge Condition Table +INSERT INTO UserBadgeCondition (badge_id, condition_id) VALUES +(1, 1), +(2, 2); + +-- Boards Table +INSERT INTO Boards (name, description, status) VALUES +('์šด๋™๊ฒŒ์‹œํŒ', 'A place for general topics', 'basic'), +('ํ•™์—…๊ฒŒ์‹œํŒ', 'Important announcements', 'pinned'); + +--Board Categories Table +INSERT INTO Board_Category (board_id, category_id) VALUES +(1, 8), +(2, 10); + +--Challenge Categories Table +INSERT INTO Challenge_Category (challenge_id, category_id) VALUES +(1, 1), +(2, 2); + +-- Challenge Keywords Table +INSERT INTO Challenge_Keyword (challenge_id, keyword_id) VALUES +(1, 1), +(2, 2); + +-- Frequencies Table +INSERT INTO Frequencies (challenge_id, frequencyType, frequencyValue) VALUES +(1, 'weeklyCount', '{"count": 5}'), +(2, 'specificDays', '{"days": ["Monday", "Wednesday", "Friday"]}'); + +-- KickOuts Table +INSERT INTO KickOuts (userChallenge_id, challengeType, created_at) VALUES +(3, 'study', NOW()), +(4, 'basic', NOW()); + +--Scrap Table +INSERT INTO Scraps (user_id, scrapTarget1_id, scrapTarget2_id, scrapType, created_at) VALUES +(1, 5, 6, 'post', NOW()), +(2, 6, 5, 'verification', NOW()); + +-- Temporary Verification Table +INSERT INTO TemporaryVerifications (user_id, verification_id, challengeType, title, content, created_at, updated_at) VALUES +(1, 1, 'study', 'Temporary Title', 'Temporary content for study', NOW(), NOW()), +(2, 2, 'basic', 'Temporary Title 2', 'Temporary content for basic', NOW(), NOW()); From 5de04a0b32df74920fa6a44b3c2031fd238cb451 Mon Sep 17 00:00:00 2001 From: Minkyung02 Date: Tue, 14 Jan 2025 21:34:27 +0900 Subject: [PATCH 4/6] Feat: modify-database Fix-null --- prisma/schema.prisma | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c60fcf2..35f0817 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,11 +16,11 @@ datasource db { model User { id Int @id @default(autoincrement()) userBadge1 UserBadge? @relation("Badge1", fields: [userBadge1_id], references: [id]) - userBadge1_id Int + userBadge1_id Int? userBadge2 UserBadge? @relation("Badge2", fields: [userBadge2_id], references: [id]) - userBadge2_id Int + userBadge2_id Int? userBadge3 UserBadge? @relation("Badge3", fields: [userBadge3_id], references: [id]) - userBadge3_id Int + userBadge3_id Int? name String @db.VarChar(10) gender Gender? email String @db.VarChar(255) From 9d8a2a2372fe7d0e7cb1da10c84088c064c9da05 Mon Sep 17 00:00:00 2001 From: sehwanii_mac Date: Tue, 14 Jan 2025 22:02:40 +0900 Subject: [PATCH 5/6] HotFix: Fix swagger annotation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Open API ๋ฒ„์ „์— ๋งž์ง€ ์•Š๋Š” ๋ฌธ๋ฒ•์„ ์‚ฌ์šฉํ•˜์—ฌ description์ด ๋ˆ„๋ฝ๋˜๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. description์˜ ์œ„์น˜๋ฅผ requestbody ๋ฐ–์œผ๋กœ ์˜ฎ๊ฒจ ์ˆ˜์ •ํ•˜์˜€์Šต๋‹ˆ๋‹ค. Resolves: #17 --- src/app.js | 2 +- src/controllers/auth.controller.js | 14 +-- src/controllers/board.controller.js | 108 +++++++++--------- src/controllers/challenge.controller.js | 55 --------- src/controllers/challenge/list.controller.js | 2 +- .../challenge/participation.controller.js | 4 +- src/controllers/message.controller.js | 4 +- src/controllers/post.controller.js | 8 +- src/controllers/users.controller.js | 8 +- .../verification/comment.controller.js | 4 +- .../verification/like.controller.js | 5 +- .../verification/scrap.controller.js | 4 +- .../verification/verification.controller.js | 6 +- 13 files changed, 85 insertions(+), 139 deletions(-) delete mode 100644 src/controllers/challenge.controller.js diff --git a/src/app.js b/src/app.js index e17f9ec..268b9b6 100644 --- a/src/app.js +++ b/src/app.js @@ -19,6 +19,6 @@ app.use('/api/v1/challenge', challengeRoutes); app.use('/api/v1/message', messageRoutes); app.use('/api/v1/board', boardRoutes); app.use('/api/v1/post', postRoutes); -app.use('api/v1/', verificationRoutes); +app.use('/api/v1', verificationRoutes); export default app; diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index 66ef6ca..e3ee5e5 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -5,6 +5,7 @@ const emailLogin = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: '๋กœ๊ทธ์ธ ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -15,7 +16,6 @@ const emailLogin = () => { }, required: ['email', 'password'] }, - description: '๋กœ๊ทธ์ธ ์š”์ฒญ ์ •๋ณด' } } }; @@ -71,6 +71,7 @@ const kakaoLogin = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: '์นด์นด์˜ค OAuth ํ† ํฐ ์ธ์ฆ ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -80,7 +81,6 @@ const kakaoLogin = () => { }, required: ['kakaoAccessToken'] }, - description: '์นด์นด์˜ค OAuth ํ† ํฐ ์ธ์ฆ ์š”์ฒญ ์ •๋ณด' } } }; @@ -135,6 +135,7 @@ const naverLogin = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: '๋„ค์ด๋ฒ„ OAuth ํ† ํฐ ์ธ์ฆ ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -144,7 +145,6 @@ const naverLogin = () => { }, required: ['naverAccessToken'] }, - description: '๋„ค์ด๋ฒ„ OAuth ํ† ํฐ ์ธ์ฆ ์š”์ฒญ ์ •๋ณด' } } }; @@ -199,6 +199,7 @@ const findEmail = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: '์ด๋ฉ”์ผ ์ฐพ๊ธฐ ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -209,7 +210,6 @@ const findEmail = () => { }, required: ['name', 'phoneNumber'] }, - description: '์ด๋ฉ”์ผ ์ฐพ๊ธฐ ์š”์ฒญ ์ •๋ณด' } } }; @@ -263,6 +263,7 @@ const ressetPasswordByPhone = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: '์ด๋ฉ”์ผ ์ฐพ๊ธฐ ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -273,7 +274,6 @@ const ressetPasswordByPhone = () => { }, required: ['name', 'phoneNumber'] }, - description: '์ด๋ฉ”์ผ ์ฐพ๊ธฐ ์š”์ฒญ ์ •๋ณด' } } }; @@ -327,6 +327,7 @@ const ressetPasswordByEmail = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: '๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -337,7 +338,6 @@ const ressetPasswordByEmail = () => { }, required: ['email', 'newPassword'] }, - description: '๋น„๋ฐ€๋ฒˆํ˜ธ ์žฌ์„ค์ • ์š”์ฒญ ์ •๋ณด' } } }; @@ -391,6 +391,7 @@ const register = () => { #swagger.tags = ['Auth']; #swagger.requestBody = { required: true, + description: 'ํšŒ์›๊ฐ€์ž… ์š”์ฒญ ์ •๋ณด', content: { 'application/json': { schema: { @@ -403,7 +404,6 @@ const register = () => { }, required: ['email', 'password', 'name', 'phoneNumber'] }, - description: 'ํšŒ์›๊ฐ€์ž… ์š”์ฒญ ์ •๋ณด' } } }; diff --git a/src/controllers/board.controller.js b/src/controllers/board.controller.js index 8f910c1..ca40a21 100644 --- a/src/controllers/board.controller.js +++ b/src/controllers/board.controller.js @@ -78,8 +78,8 @@ const getBoardCategories = () => { }; const createBoard = () => { /** - #swagger.summary = '๊ฒŒ์‹œ๊ธ€ ์ƒ๋‹จ ๊ณ ์ • API'; - #swagger.description = 'ํŠน์ • ๊ฒŒ์‹œ๊ธ€์„ ๊ฒŒ์‹œํŒ ์ƒ๋‹จ์— ๊ณ ์ •ํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.'; + #swagger.summary = '๊ฒŒ์‹œํŒ ์ƒ์„ฑ API'; + #swagger.description = '์‚ฌ์šฉ์ž๊ฐ€ ์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ์„ ์ƒ์„ฑํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.'; #swagger.tags = ['Board']; #swagger.parameters['Authorization'] = { in: 'header', @@ -87,23 +87,25 @@ const createBoard = () => { schema: { type: 'string', example: 'Bearer ' }, description: '์ธ์ฆ์„ ์œ„ํ•œ ์•ก์„ธ์Šค ํ† ํฐ' }; - #swagger.parameters['boardID'] = { - in: 'path', - required: true, - schema: { type: 'integer', example: 1 }, - description: '๊ฒŒ์‹œํŒ ID' - }; #swagger.requestBody = { - required: false, + required: true, + description: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์ƒ์„ฑ ์š”์ฒญ ๋ฐ์ดํ„ฐ', content: { 'application/json': { - schema: { type: 'object' }, - description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' + schema: { + type: 'object', + properties: { + name: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์ด๋ฆ„' }, + description: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์„ค๋ช…' }, + category: { type: 'string', example: '์šด๋™' } + }, + required: ['name', 'description', 'category'] + }, } } }; - #swagger.responses[200] = { - description: '๊ฒŒ์‹œ๊ธ€ ์ƒ๋‹จ ๊ณ ์ • ์„ฑ๊ณต', + #swagger.responses[201] = { + description: '๊ฒŒ์‹œํŒ ์ƒ์„ฑ ์„ฑ๊ณต', content: { 'application/json': { schema: { @@ -114,9 +116,15 @@ const createBoard = () => { success: { type: 'object', properties: { - message: { type: 'string', example: 'Post pinned successfully' }, - boardId: { type: 'integer', example: 3 }, - status: { type: 'string', example: 'pinned' } + message: { type: 'string', example: 'new board created successfully' }, + data: { + type: 'object', + properties: { + name: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์ด๋ฆ„' }, + description: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์„ค๋ช…' }, + category: { type: 'string', example: '์šด๋™' } + } + } } } } @@ -124,29 +132,29 @@ const createBoard = () => { } } }; - #swagger.responses[401] = { - description: '์ธ์ฆ ์‹คํŒจ', + #swagger.responses[400] = { + description: '์ž˜๋ชป๋œ ์š”์ฒญ', content: { 'application/json': { schema: { type: 'object', properties: { resultType: { type: 'string', example: 'FAILURE' }, - error: { type: 'string', example: 'Unauthorized access.' } + error: { type: 'string', example: 'Invalid input data.' } } } } } }; - #swagger.responses[404] = { - description: '๊ฒŒ์‹œํŒ์„ ์ฐพ์„ ์ˆ˜ ์—†์Œ', + #swagger.responses[401] = { + description: '์ธ์ฆ ์‹คํŒจ', content: { 'application/json': { schema: { type: 'object', properties: { - resultType: { type: 'string', example: 'NOT_FOUND' }, - error: { type: 'string', example: 'Board not found.' } + resultType: { type: 'string', example: 'FAILURE' }, + error: { type: 'string', example: 'Unauthorized access.' } } } } @@ -170,8 +178,8 @@ const createBoard = () => { }; const updateBoardPinned = () => { /** - #swagger.summary = '๊ฒŒ์‹œํŒ ์ƒ์„ฑ API'; - #swagger.description = '์‚ฌ์šฉ์ž๊ฐ€ ์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ์„ ์ƒ์„ฑํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.'; + #swagger.summary = '๊ฒŒ์‹œ๊ธ€ ์ƒ๋‹จ ๊ณ ์ • API'; + #swagger.description = 'ํŠน์ • ๊ฒŒ์‹œ๊ธ€์„ ๊ฒŒ์‹œํŒ ์ƒ๋‹จ์— ๊ณ ์ •ํ•˜๋Š” API์ž…๋‹ˆ๋‹ค.'; #swagger.tags = ['Board']; #swagger.parameters['Authorization'] = { in: 'header', @@ -179,25 +187,23 @@ const updateBoardPinned = () => { schema: { type: 'string', example: 'Bearer ' }, description: '์ธ์ฆ์„ ์œ„ํ•œ ์•ก์„ธ์Šค ํ† ํฐ' }; - #swagger.requestBody = { + #swagger.parameters['boardID'] = { + in: 'path', required: true, + schema: { type: 'integer', example: 1 }, + description: '๊ฒŒ์‹œํŒ ID' + }; + #swagger.requestBody = { + required: false, + description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.', content: { 'application/json': { - schema: { - type: 'object', - properties: { - name: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์ด๋ฆ„' }, - description: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์„ค๋ช…' }, - category: { type: 'string', example: '์šด๋™' } - }, - required: ['name', 'description', 'category'] - }, - description: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์ƒ์„ฑ ์š”์ฒญ ๋ฐ์ดํ„ฐ' + schema: { type: 'object' }, } } }; - #swagger.responses[201] = { - description: '๊ฒŒ์‹œํŒ ์ƒ์„ฑ ์„ฑ๊ณต', + #swagger.responses[200] = { + description: '๊ฒŒ์‹œ๊ธ€ ์ƒ๋‹จ ๊ณ ์ • ์„ฑ๊ณต', content: { 'application/json': { schema: { @@ -208,15 +214,9 @@ const updateBoardPinned = () => { success: { type: 'object', properties: { - message: { type: 'string', example: 'new board created successfully' }, - data: { - type: 'object', - properties: { - name: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์ด๋ฆ„' }, - description: { type: 'string', example: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œํŒ ์„ค๋ช…' }, - category: { type: 'string', example: '์šด๋™' } - } - } + message: { type: 'string', example: 'Post pinned successfully' }, + boardId: { type: 'integer', example: 3 }, + status: { type: 'string', example: 'pinned' } } } } @@ -224,29 +224,29 @@ const updateBoardPinned = () => { } } }; - #swagger.responses[400] = { - description: '์ž˜๋ชป๋œ ์š”์ฒญ', + #swagger.responses[401] = { + description: '์ธ์ฆ ์‹คํŒจ', content: { 'application/json': { schema: { type: 'object', properties: { resultType: { type: 'string', example: 'FAILURE' }, - error: { type: 'string', example: 'Invalid input data.' } + error: { type: 'string', example: 'Unauthorized access.' } } } } } }; - #swagger.responses[401] = { - description: '์ธ์ฆ ์‹คํŒจ', + #swagger.responses[404] = { + description: '๊ฒŒ์‹œํŒ์„ ์ฐพ์„ ์ˆ˜ ์—†์Œ', content: { 'application/json': { schema: { type: 'object', properties: { - resultType: { type: 'string', example: 'FAILURE' }, - error: { type: 'string', example: 'Unauthorized access.' } + resultType: { type: 'string', example: 'NOT_FOUND' }, + error: { type: 'string', example: 'Board not found.' } } } } diff --git a/src/controllers/challenge.controller.js b/src/controllers/challenge.controller.js deleted file mode 100644 index c2b7532..0000000 --- a/src/controllers/challenge.controller.js +++ /dev/null @@ -1,55 +0,0 @@ -const getChallengeCategory = () => {}; -const getWeeklyHotChallenge = () => {}; -const getChallengeList = () => {}; -const searchChallenge = () => {}; -const getChallengeDetail = () => {}; -const createChallenge = () => {}; -const joinChallenge = () => {}; -const likeChallenge = () => {}; -const participateInChallenge = () => {}; -const getChallengeVerificationStatus = () => {}; -const getWeeklyVerification = () => {}; -const getSpecificVerification = () => {}; -const likeSpecificVerification = () => {}; -const unlikeSpecificVerification = () => {}; -const getVerificationComments = () => {}; -const postVerificationComment = () => {}; -const updateVerificationComment = () => {}; -const scrapVerification = () => {}; -const unscrapVerification = () => {}; -const cameraVerification = () => {}; -const textVerification = () => {}; -const getChallengeParticipantsList = () => {}; -const kickChallengeParticipant = () => {}; -const getChallengeCalendar = () => {}; -const getTemporaryVerification = () => {}; -const deleteTemporaryVerification = () => {}; - -export default { - getChallengeCategory, - getWeeklyHotChallenge, - getChallengeList, - searchChallenge, - getChallengeDetail, - createChallenge, - joinChallenge, - likeChallenge, - participateInChallenge, - getChallengeVerificationStatus, - getWeeklyVerification, - getSpecificVerification, - likeSpecificVerification, - unlikeSpecificVerification, - getVerificationComments, - postVerificationComment, - updateVerificationComment, - scrapVerification, - unscrapVerification, - cameraVerification, - textVerification, - getChallengeParticipantsList, - kickChallengeParticipant, - getChallengeCalendar, - getTemporaryVerification, - deleteTemporaryVerification, -}; diff --git a/src/controllers/challenge/list.controller.js b/src/controllers/challenge/list.controller.js index 6feb36a..d845edd 100644 --- a/src/controllers/challenge/list.controller.js +++ b/src/controllers/challenge/list.controller.js @@ -319,6 +319,7 @@ const createChallenge = () => { }; #swagger.requestBody = { required: true, + description: '์ฑŒ๋ฆฐ์ง€ ๊ฐœ์„ค ์š”์ฒญ ๋ณธ๋ฌธ', content: { 'application/json': { schema: { @@ -346,7 +347,6 @@ const createChallenge = () => { }, required: ['category', 'type', 'profileImage', 'duration', 'maxParticipants', 'verificationMethod', 'rule', 'keywords'] }, - description: '์ฑŒ๋ฆฐ์ง€ ๊ฐœ์„ค ์š”์ฒญ ๋ณธ๋ฌธ' } } }; diff --git a/src/controllers/challenge/participation.controller.js b/src/controllers/challenge/participation.controller.js index 576ab01..68ed0bd 100644 --- a/src/controllers/challenge/participation.controller.js +++ b/src/controllers/challenge/participation.controller.js @@ -23,6 +23,7 @@ const joinChallenge = () => { }; #swagger.requestBody = { required: true, + description: '์ฐธ๊ฐ€ ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -33,7 +34,6 @@ const joinChallenge = () => { }, required: ['userId', 'joinDate'] }, - description: '์ฐธ๊ฐ€ ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ' } } }; @@ -150,6 +150,7 @@ const likeChallenge = () => { }; #swagger.requestBody = { required: true, + description: '์ข‹์•„์š” ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -161,7 +162,6 @@ const likeChallenge = () => { }, required: ['userId', 'likeId', 'action'] }, - description: '์ข‹์•„์š” ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ' } } }; diff --git a/src/controllers/message.controller.js b/src/controllers/message.controller.js index d9d874c..d6e755d 100644 --- a/src/controllers/message.controller.js +++ b/src/controllers/message.controller.js @@ -17,6 +17,7 @@ const sendMessage = () => { }; #swagger.requestBody = { required: true, + description: '์ „์†กํ•  ์ชฝ์ง€์˜ ๋‚ด์šฉ ๋ฐ ์ˆ˜์‹ ์ž ID', content: { 'application/json': { schema: { @@ -27,7 +28,6 @@ const sendMessage = () => { }, required: ['receivedUser_id', 'content'] }, - description: '์ „์†กํ•  ์ชฝ์ง€์˜ ๋‚ด์šฉ ๋ฐ ์ˆ˜์‹ ์ž ID' } } }; @@ -205,6 +205,7 @@ const leaveMessage = () => { }; #swagger.requestBody = { required: true, + description: '๋‚˜๊ฐ€๋ ค๋Š” ์ชฝ์ง€ํ•จ์˜ ์ƒ๋Œ€๋ฐฉ ID', content: { 'application/json': { schema: { @@ -214,7 +215,6 @@ const leaveMessage = () => { }, required: ['chat_partner_id'] }, - description: '๋‚˜๊ฐ€๋ ค๋Š” ์ชฝ์ง€ํ•จ์˜ ์ƒ๋Œ€๋ฐฉ ID' } } }; diff --git a/src/controllers/post.controller.js b/src/controllers/post.controller.js index 743695e..79f42b0 100644 --- a/src/controllers/post.controller.js +++ b/src/controllers/post.controller.js @@ -492,6 +492,7 @@ const createPost = () => { }; #swagger.requestBody = { required: true, + description: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ ์š”์ฒญ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -507,7 +508,6 @@ const createPost = () => { }, required: ['title', 'content', 'anonymity'] }, - description: '์ƒˆ๋กœ์šด ๊ฒŒ์‹œ๊ธ€ ์ž‘์„ฑ ์š”์ฒญ ๋ฐ์ดํ„ฐ' } } }; @@ -595,10 +595,10 @@ const likePost = () => { }; #swagger.requestBody = { required: false, + description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.', content: { 'application/json': { schema: { type: 'object' }, - description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' } } }; @@ -685,6 +685,7 @@ const commentOnPost = () => { }; #swagger.requestBody = { required: true, + description: '๋Œ“๊ธ€ ๋‚ด์šฉ', content: { 'application/json': { schema: { @@ -694,7 +695,6 @@ const commentOnPost = () => { }, required: ['content'] }, - description: '๋Œ“๊ธ€ ๋‚ด์šฉ' } } }; @@ -796,10 +796,10 @@ const savePost = () => { }; #swagger.requestBody = { required: false, + description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.', content: { 'application/json': { schema: { type: 'object' }, - description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' } } }; diff --git a/src/controllers/users.controller.js b/src/controllers/users.controller.js index 3f074ab..e97c821 100644 --- a/src/controllers/users.controller.js +++ b/src/controllers/users.controller.js @@ -84,6 +84,7 @@ const putMe = () => { }; #swagger.requestBody = { required: true, + description: '์‚ฌ์šฉ์ž ์ •๋ณด ์ˆ˜์ • ์š”์ฒญ ์ •๋ณด' content: { 'application/json': { schema: { @@ -96,7 +97,6 @@ const putMe = () => { }, required: ['name', 'email', 'gender', 'profilePhoto'] }, - description: '์‚ฌ์šฉ์ž ์ •๋ณด ์ˆ˜์ • ์š”์ฒญ ์ •๋ณด' } } }; @@ -432,10 +432,10 @@ const postUserFollow = () => { }; #swagger.requestBody = { required: false, + description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' content: { 'application/json': { schema: { type: 'object' }, - description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' } } }; @@ -509,10 +509,10 @@ const deleteUserFollow = () => { }; #swagger.requestBody = { required: false, + description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' content: { 'application/json': { schema: { type: 'object' }, - description: '์ด ์š”์ฒญ์—๋Š” ๋ณธ๋ฌธ์ด ํ•„์š”ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.' } } }; @@ -653,6 +653,7 @@ const blockUser = () => { }; #swagger.requestBody = { required: true, + description: '์ฐจ๋‹จํ•  ์ด์šฉ์ž์˜ ID', content: { 'application/json': { schema: { @@ -662,7 +663,6 @@ const blockUser = () => { }, required: ['user_id'] }, - description: '์ฐจ๋‹จํ•  ์ด์šฉ์ž์˜ ID' } } }; diff --git a/src/controllers/verification/comment.controller.js b/src/controllers/verification/comment.controller.js index 2c42c38..6bd63f4 100644 --- a/src/controllers/verification/comment.controller.js +++ b/src/controllers/verification/comment.controller.js @@ -149,6 +149,7 @@ const postVerificationComment = () => { }; #swagger.requestBody = { required: true, + description: '๋Œ“๊ธ€ ์ž‘์„ฑ ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -160,7 +161,6 @@ const postVerificationComment = () => { }, required: ['content', 'userId', 'username'] }, - description: '๋Œ“๊ธ€ ์ž‘์„ฑ ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ' } } }; @@ -285,6 +285,7 @@ const updateVerificationComment = () => { }; #swagger.requestBody = { required: true, + description: '๋Œ“๊ธ€ ์ˆ˜์ • ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -294,7 +295,6 @@ const updateVerificationComment = () => { }, required: ['content'] }, - description: '๋Œ“๊ธ€ ์ˆ˜์ • ์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ' } } }; diff --git a/src/controllers/verification/like.controller.js b/src/controllers/verification/like.controller.js index 310958b..ef59d9f 100644 --- a/src/controllers/verification/like.controller.js +++ b/src/controllers/verification/like.controller.js @@ -23,13 +23,14 @@ const likeSpecificVerification = () => { }; #swagger.requestBody = { required: false, + description: '์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.', content: { 'application/json': { schema: { type: 'object', properties: {}, }, - description: '์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.' + } } }; @@ -146,6 +147,7 @@ const unlikeSpecificVerification = () => { }; #swagger.requestBody = { required: true, + description: '์ข‹์•„์š” ์ทจ์†Œ ์š”์ฒญ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -155,7 +157,6 @@ const unlikeSpecificVerification = () => { }, required: ['likeId'] }, - description: '์ข‹์•„์š” ์ทจ์†Œ ์š”์ฒญ ๋ฐ์ดํ„ฐ' } } }; diff --git a/src/controllers/verification/scrap.controller.js b/src/controllers/verification/scrap.controller.js index b3f9473..a8295c8 100644 --- a/src/controllers/verification/scrap.controller.js +++ b/src/controllers/verification/scrap.controller.js @@ -23,13 +23,13 @@ export const scrapVerification = () => { }; #swagger.requestBody = { required: false, + description: '์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.', content: { 'application/json': { schema: { type: 'object', properties: {}, }, - description: '์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.' } } }; @@ -147,6 +147,7 @@ export const unscrapVerification = () => { }; #swagger.requestBody = { required: true, + description: '์Šคํฌ๋žฉ ์ทจ์†Œ ์š”์ฒญ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -156,7 +157,6 @@ export const unscrapVerification = () => { }, required: ['scrapId'] }, - description: '์Šคํฌ๋žฉ ์ทจ์†Œ ์š”์ฒญ ๋ฐ์ดํ„ฐ' } } }; diff --git a/src/controllers/verification/verification.controller.js b/src/controllers/verification/verification.controller.js index 1a17f2e..a035d4e 100644 --- a/src/controllers/verification/verification.controller.js +++ b/src/controllers/verification/verification.controller.js @@ -17,13 +17,13 @@ const getChallengeVerificationStatus = () => { }; #swagger.requestBody = { required: false, + description: '์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.', content: { 'application/json': { schema: { type: 'object', properties: {} }, - description: '์š”์ฒญ ๋ณธ๋ฌธ ๋ฐ์ดํ„ฐ๋Š” ๋น„์–ด ์žˆ์Šต๋‹ˆ๋‹ค.' } } }; @@ -373,6 +373,7 @@ const cameraVerification = () => { }; #swagger.requestBody = { required: true, + description: '์‚ฌ์ง„ ์—…๋กœ๋“œ๋ฅผ ์œ„ํ•œ multipart/form-data ํ˜•์‹์˜ ์š”์ฒญ ๋ฐ์ดํ„ฐ', content: { 'multipart/form-data': { schema: { @@ -386,7 +387,6 @@ const cameraVerification = () => { }, required: ['photoUrl'] }, - description: '์‚ฌ์ง„ ์—…๋กœ๋“œ๋ฅผ ์œ„ํ•œ multipart/form-data ํ˜•์‹์˜ ์š”์ฒญ ๋ฐ์ดํ„ฐ' } } }; @@ -516,6 +516,7 @@ const textVerification = () => { }; #swagger.requestBody = { required: true, + description: '์ฑŒ๋ฆฐ์ง€ ๊ธ€ ์ธ์ฆ ์š”์ฒญ ๋ฐ์ดํ„ฐ', content: { 'application/json': { schema: { @@ -528,7 +529,6 @@ const textVerification = () => { }, required: ['title', 'content', 'textUrl', 'question'] }, - description: '์ฑŒ๋ฆฐ์ง€ ๊ธ€ ์ธ์ฆ ์š”์ฒญ ๋ฐ์ดํ„ฐ' } } }; From 97cf7a044a8d0e5f7e7f8c5d798839136d692ed3 Mon Sep 17 00:00:00 2001 From: Minkyung02 Date: Wed, 15 Jan 2025 18:32:10 +0900 Subject: [PATCH 6/6] Feat: modify-database Fix-atabase-update prisma files --- .../migration.sql | 394 ++++++++++++++++++ .../20250114132920_v2/migration.sql | 134 ++++++ .../20250115081846_v3/migration.sql | 47 +++ .../20250115083611_v4/migration.sql | 8 + prisma/migrations/migration_lock.toml | 3 + prisma/schema.prisma | 35 +- prisma/seed.js | 114 +++++ 7 files changed, 716 insertions(+), 19 deletions(-) create mode 100644 prisma/migrations/20250113120101_hrr_db_20250113/migration.sql create mode 100644 prisma/migrations/20250114132920_v2/migration.sql create mode 100644 prisma/migrations/20250115081846_v3/migration.sql create mode 100644 prisma/migrations/20250115083611_v4/migration.sql create mode 100644 prisma/migrations/migration_lock.toml create mode 100644 prisma/seed.js diff --git a/prisma/migrations/20250113120101_hrr_db_20250113/migration.sql b/prisma/migrations/20250113120101_hrr_db_20250113/migration.sql new file mode 100644 index 0000000..aac2a86 --- /dev/null +++ b/prisma/migrations/20250113120101_hrr_db_20250113/migration.sql @@ -0,0 +1,394 @@ +-- CreateTable +CREATE TABLE `Users` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `userBadge1_id` INTEGER NOT NULL, + `userBadge2_id` INTEGER NOT NULL, + `userBadge3_id` INTEGER NOT NULL, + `name` VARCHAR(10) NOT NULL, + `gender` VARCHAR(255) NOT NULL, + `email` VARCHAR(255) NOT NULL, + `phoneNumber` VARCHAR(15) NOT NULL, + `password` VARCHAR(255) NOT NULL, + `created_at` DATETIME(6) NOT NULL, + `updated_at` DATETIME(6) NOT NULL, + `inactiveDate` DATETIME(6) NOT NULL, + `profilePhoto` VARCHAR(255) NULL, + `level` INTEGER NOT NULL, + `followerCount` INTEGER NOT NULL, + `followingCount` INTEGER NOT NULL, + `points` INTEGER NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Keywords` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(15) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `ChallengeLikes` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `challenge_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Comments` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `post_id` INTEGER NOT NULL, + `verification_id` INTEGER NOT NULL, + `content` TEXT NULL, + `created_at` DATETIME(6) NULL, + `updated_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Boards` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(10) NOT NULL, + `description` VARCHAR(120) NULL, + `status` ENUM('basic', 'pinned', 'default') NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Posts` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `board_id` INTEGER NOT NULL, + `title` VARCHAR(50) NULL, + `content` VARCHAR(200) NULL, + `anonymous` BOOLEAN NULL, + `created_at` DATETIME(6) NULL, + `updated_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `PostLikes` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `post_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Messages` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `receivedUser_id` INTEGER NOT NULL, + `sendUser_id` INTEGER NOT NULL, + `content` TEXT NULL, + `created_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Verifications` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `userChallenge_id` INTEGER NOT NULL, + `challengeType` ENUM('study', 'basic') NOT NULL, + `type` ENUM('camera', 'text') NOT NULL, + `photoUrl` VARCHAR(255) NULL, + `title` VARCHAR(20) NULL, + `content` VARCHAR(200) NULL, + `question` BOOLEAN NULL, + `textUrl` VARCHAR(255) NULL, + `status` ENUM('verified', 'unverified') NOT NULL, + `created_at` DATETIME(6) NULL, + `updated_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `KickOuts` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `userChallenge_id` INTEGER NOT NULL, + `challengeType` ENUM('study', 'basic') NOT NULL, + `created_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Follows` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `follower_id` INTEGER NOT NULL, + `following_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Badges` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(50) NULL, + `icon` VARCHAR(255) NULL, + `description` TEXT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `User_Badge` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `badge_id` INTEGER NOT NULL, + `created_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Category` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(15) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `FavorType` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` VARCHAR(10) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `User_CategoryType` ( + `id` INTEGER NOT NULL, + `user_id` INTEGER NOT NULL, + `category_id` INTEGER NOT NULL, + `favorType_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`, `user_id`, `category_id`, `favorType_id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Challenge_Category` ( + `id` INTEGER NOT NULL, + `category_id` INTEGER NOT NULL, + `challenge_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`, `category_id`, `challenge_id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Board_Category` ( + `id` INTEGER NOT NULL, + `board_id` INTEGER NOT NULL, + `category_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`, `board_id`, `category_id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Scraps` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `scrapTarget1_id` INTEGER NOT NULL, + `scrapTarget2_id` INTEGER NOT NULL, + `scrapType` ENUM('post', 'verification') NOT NULL, + `created_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `TemporaryVerifications` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `verification_id` INTEGER NOT NULL, + `challengeType` ENUM('study', 'basic') NOT NULL, + `title` VARCHAR(20) NULL, + `content` VARCHAR(200) NULL, + `created_at` DATETIME(6) NULL, + `updated_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Challenges` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `owner_id` INTEGER NOT NULL, + `name` VARCHAR(10) NULL, + `type` ENUM('study', 'basic') NOT NULL, + `description` VARCHAR(120) NULL, + `challengeImage` VARCHAR(255) NULL, + `status` ENUM('open', 'ongoing', 'completed') NOT NULL, + `maxParticipants` INTEGER NULL, + `verificationType` ENUM('camera', 'text') NOT NULL, + `rule` TEXT NULL, + `created_at` DATETIME(6) NULL, + `updated_at` DATETIME(6) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Frequencies` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `challenge_id` INTEGER NOT NULL, + `frequencyType` ENUM('weeklyCount', 'specificDays') NOT NULL, + `frequencyValue` JSON NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `User_Challenge` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `challenge_id` INTEGER NOT NULL, + `user_id` INTEGER NOT NULL, + `challengeStatus` ENUM('open', 'ongoing', 'completed') NOT NULL, + `joinDate` DATETIME(6) NULL, + `endDate` DATETIME(6) NULL, + `verifyCount` INTEGER NULL, + `unverifiedCount` INTEGER NULL, + `status` ENUM('kick', 'active') NOT NULL, + `warn` INTEGER NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Challenge_Keyword` ( + `id` INTEGER NOT NULL, + `challenge_id` INTEGER NOT NULL, + `keyword_id` INTEGER NOT NULL, + + PRIMARY KEY (`id`, `challenge_id`, `keyword_id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- AddForeignKey +ALTER TABLE `Users` ADD CONSTRAINT `Users_userBadge1_id_fkey` FOREIGN KEY (`userBadge1_id`) REFERENCES `User_Badge`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Users` ADD CONSTRAINT `Users_userBadge2_id_fkey` FOREIGN KEY (`userBadge2_id`) REFERENCES `User_Badge`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Users` ADD CONSTRAINT `Users_userBadge3_id_fkey` FOREIGN KEY (`userBadge3_id`) REFERENCES `User_Badge`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `ChallengeLikes` ADD CONSTRAINT `ChallengeLikes_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `ChallengeLikes` ADD CONSTRAINT `ChallengeLikes_challenge_id_fkey` FOREIGN KEY (`challenge_id`) REFERENCES `Challenges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Comments` ADD CONSTRAINT `Comments_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Comments` ADD CONSTRAINT `Comments_post_id_fkey` FOREIGN KEY (`post_id`) REFERENCES `Posts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Comments` ADD CONSTRAINT `Comments_verification_id_fkey` FOREIGN KEY (`verification_id`) REFERENCES `Verifications`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Posts` ADD CONSTRAINT `Posts_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Posts` ADD CONSTRAINT `Posts_board_id_fkey` FOREIGN KEY (`board_id`) REFERENCES `Boards`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `PostLikes` ADD CONSTRAINT `PostLikes_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `PostLikes` ADD CONSTRAINT `PostLikes_post_id_fkey` FOREIGN KEY (`post_id`) REFERENCES `Posts`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Messages` ADD CONSTRAINT `Messages_receivedUser_id_fkey` FOREIGN KEY (`receivedUser_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Messages` ADD CONSTRAINT `Messages_sendUser_id_fkey` FOREIGN KEY (`sendUser_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Verifications` ADD CONSTRAINT `Verifications_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Verifications` ADD CONSTRAINT `Verifications_userChallenge_id_fkey` FOREIGN KEY (`userChallenge_id`) REFERENCES `User_Challenge`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `KickOuts` ADD CONSTRAINT `KickOuts_userChallenge_id_fkey` FOREIGN KEY (`userChallenge_id`) REFERENCES `User_Challenge`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Follows` ADD CONSTRAINT `Follows_follower_id_fkey` FOREIGN KEY (`follower_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Follows` ADD CONSTRAINT `Follows_following_id_fkey` FOREIGN KEY (`following_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Badge` ADD CONSTRAINT `User_Badge_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Badge` ADD CONSTRAINT `User_Badge_badge_id_fkey` FOREIGN KEY (`badge_id`) REFERENCES `Badges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_CategoryType` ADD CONSTRAINT `User_CategoryType_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_CategoryType` ADD CONSTRAINT `User_CategoryType_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `Category`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_CategoryType` ADD CONSTRAINT `User_CategoryType_favorType_id_fkey` FOREIGN KEY (`favorType_id`) REFERENCES `FavorType`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Challenge_Category` ADD CONSTRAINT `Challenge_Category_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `Category`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Challenge_Category` ADD CONSTRAINT `Challenge_Category_challenge_id_fkey` FOREIGN KEY (`challenge_id`) REFERENCES `Challenges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Board_Category` ADD CONSTRAINT `Board_Category_board_id_fkey` FOREIGN KEY (`board_id`) REFERENCES `Boards`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Board_Category` ADD CONSTRAINT `Board_Category_category_id_fkey` FOREIGN KEY (`category_id`) REFERENCES `Category`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Scraps` ADD CONSTRAINT `Scraps_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Scraps` ADD CONSTRAINT `Scraps_scrapTarget1_id_fkey` FOREIGN KEY (`scrapTarget1_id`) REFERENCES `Verifications`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Scraps` ADD CONSTRAINT `Scraps_scrapTarget2_id_fkey` FOREIGN KEY (`scrapTarget2_id`) REFERENCES `Verifications`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `TemporaryVerifications` ADD CONSTRAINT `TemporaryVerifications_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `TemporaryVerifications` ADD CONSTRAINT `TemporaryVerifications_verification_id_fkey` FOREIGN KEY (`verification_id`) REFERENCES `Verifications`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Challenges` ADD CONSTRAINT `Challenges_owner_id_fkey` FOREIGN KEY (`owner_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Frequencies` ADD CONSTRAINT `Frequencies_challenge_id_fkey` FOREIGN KEY (`challenge_id`) REFERENCES `Challenges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Challenge` ADD CONSTRAINT `User_Challenge_challenge_id_fkey` FOREIGN KEY (`challenge_id`) REFERENCES `Challenges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Challenge` ADD CONSTRAINT `User_Challenge_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Challenge_Keyword` ADD CONSTRAINT `Challenge_Keyword_challenge_id_fkey` FOREIGN KEY (`challenge_id`) REFERENCES `Challenges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Challenge_Keyword` ADD CONSTRAINT `Challenge_Keyword_keyword_id_fkey` FOREIGN KEY (`keyword_id`) REFERENCES `Keywords`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20250114132920_v2/migration.sql b/prisma/migrations/20250114132920_v2/migration.sql new file mode 100644 index 0000000..beb0fb4 --- /dev/null +++ b/prisma/migrations/20250114132920_v2/migration.sql @@ -0,0 +1,134 @@ +/* + Warnings: + + - You are about to alter the column `gender` on the `Users` table. The data in that column could be lost. The data in that column will be cast from `VarChar(255)` to `Enum(EnumId(0))`. + - You are about to alter the column `level` on the `Users` table. The data in that column could be lost. The data in that column will be cast from `Int` to `Enum(EnumId(1))`. + - A unique constraint covering the columns `[follower_id,following_id]` on the table `Follows` will be added. If there are existing duplicate values, this will fail. + - Added the required column `obtain` to the `User_Badge` table without a default value. This is not possible if the table is not empty. + - Made the column `warn` on table `User_Challenge` required. This step will fail if there are existing NULL values in that column. + +*/ +-- DropForeignKey +ALTER TABLE `Users` DROP FOREIGN KEY `Users_userBadge1_id_fkey`; + +-- DropForeignKey +ALTER TABLE `Users` DROP FOREIGN KEY `Users_userBadge2_id_fkey`; + +-- DropForeignKey +ALTER TABLE `Users` DROP FOREIGN KEY `Users_userBadge3_id_fkey`; + +-- DropIndex +DROP INDEX `Users_userBadge1_id_fkey` ON `Users`; + +-- DropIndex +DROP INDEX `Users_userBadge2_id_fkey` ON `Users`; + +-- DropIndex +DROP INDEX `Users_userBadge3_id_fkey` ON `Users`; + +-- AlterTable +ALTER TABLE `Badges` ADD COLUMN `obtainedCount` INTEGER NULL, + ADD COLUMN `profileImage` VARCHAR(255) NULL, + ADD COLUMN `type` ENUM('category', 'type') NULL; + +-- AlterTable +ALTER TABLE `User_Badge` ADD COLUMN `obtain` BOOLEAN NOT NULL, + ADD COLUMN `updated_at` DATETIME(6) NULL; + +-- AlterTable +ALTER TABLE `User_Challenge` MODIFY `warn` INTEGER NOT NULL DEFAULT 0; + +-- AlterTable +ALTER TABLE `Users` ADD COLUMN `ageGroup` ENUM('10s', '20s', '30s', '40s', '50s+') NULL, + ADD COLUMN `job` ENUM('middleHighSchoolStudent', 'collegeStudent', 'jobSeeker', 'officeWorker', 'housewife') NULL, + ADD COLUMN `userCategory` ENUM('exercise', 'study', 'hobby', 'jobPreparation', 'lifestyle') NULL, + MODIFY `userBadge1_id` INTEGER NULL, + MODIFY `userBadge2_id` INTEGER NULL, + MODIFY `userBadge3_id` INTEGER NULL, + MODIFY `gender` ENUM('male', 'female') NULL, + MODIFY `level` ENUM('bronze', 'silver', 'gold', 'master', 'challenger') NULL; + +-- AlterTable +ALTER TABLE `Verifications` ADD COLUMN `deadline` DATETIME(6) NULL; + +-- CreateTable +CREATE TABLE `Goals` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `name` ENUM('health', 'diet', 'foodControl', 'smallGoal', 'studyTogether', 'makeHabit', 'studyRoutine', 'buildCapacity', 'escape_3', 'qualification') NOT NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `User_Goal` ( + `user_id` INTEGER NOT NULL, + `goal_id` INTEGER NOT NULL, + + PRIMARY KEY (`user_id`, `goal_id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Alarms` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `user_id` INTEGER NOT NULL, + `sender_id` INTEGER NULL, + `alarmType` ENUM('follow', 'verificationComment', 'postComment', 'warning', 'kickOut', 'newVerification', 'deadline') NOT NULL, + `reference_id` INTEGER NOT NULL, + `message` VARCHAR(200) NULL, + `isRead` BOOLEAN NULL, + `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `Conditions` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `badge_id` INTEGER NOT NULL, + `description` VARCHAR(191) NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `User_Badge_Condition` ( + `id` INTEGER NOT NULL AUTO_INCREMENT, + `userBadge_id` INTEGER NOT NULL, + `condition_id` INTEGER NOT NULL, + `isAchieved` BOOLEAN NULL, + + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateIndex +CREATE UNIQUE INDEX `Follows_follower_id_following_id_key` ON `Follows`(`follower_id`, `following_id`); + +-- AddForeignKey +ALTER TABLE `Users` ADD CONSTRAINT `Users_userBadge1_id_fkey` FOREIGN KEY (`userBadge1_id`) REFERENCES `User_Badge`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Users` ADD CONSTRAINT `Users_userBadge2_id_fkey` FOREIGN KEY (`userBadge2_id`) REFERENCES `User_Badge`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Users` ADD CONSTRAINT `Users_userBadge3_id_fkey` FOREIGN KEY (`userBadge3_id`) REFERENCES `User_Badge`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Goal` ADD CONSTRAINT `User_Goal_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Goal` ADD CONSTRAINT `User_Goal_goal_id_fkey` FOREIGN KEY (`goal_id`) REFERENCES `Goals`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Alarms` ADD CONSTRAINT `Alarms_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `Users`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Alarms` ADD CONSTRAINT `Alarms_sender_id_fkey` FOREIGN KEY (`sender_id`) REFERENCES `Follows`(`id`) ON DELETE SET NULL ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `Conditions` ADD CONSTRAINT `Conditions_badge_id_fkey` FOREIGN KEY (`badge_id`) REFERENCES `Badges`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Badge_Condition` ADD CONSTRAINT `User_Badge_Condition_userBadge_id_fkey` FOREIGN KEY (`userBadge_id`) REFERENCES `User_Badge`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE `User_Badge_Condition` ADD CONSTRAINT `User_Badge_Condition_condition_id_fkey` FOREIGN KEY (`condition_id`) REFERENCES `Conditions`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/prisma/migrations/20250115081846_v3/migration.sql b/prisma/migrations/20250115081846_v3/migration.sql new file mode 100644 index 0000000..c39e3d7 --- /dev/null +++ b/prisma/migrations/20250115081846_v3/migration.sql @@ -0,0 +1,47 @@ +/* + Warnings: + + - You are about to alter the column `created_at` on the `KickOuts` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `Messages` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `Posts` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `updated_at` on the `Posts` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `Scraps` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `TemporaryVerifications` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `updated_at` on the `TemporaryVerifications` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `User_Badge` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `updated_at` on the `User_Badge` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `Users` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `updated_at` on the `Users` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `created_at` on the `Verifications` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + - You are about to alter the column `updated_at` on the `Verifications` table. The data in that column could be lost. The data in that column will be cast from `DateTime(6)` to `DateTime(3)`. + +*/ +-- AlterTable +ALTER TABLE `KickOuts` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3); + +-- AlterTable +ALTER TABLE `Messages` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3); + +-- AlterTable +ALTER TABLE `Posts` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3), + MODIFY `updated_at` DATETIME(3) NULL; + +-- AlterTable +ALTER TABLE `Scraps` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3); + +-- AlterTable +ALTER TABLE `TemporaryVerifications` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3), + MODIFY `updated_at` DATETIME(3) NULL; + +-- AlterTable +ALTER TABLE `User_Badge` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3), + MODIFY `updated_at` DATETIME(3) NULL; + +-- AlterTable +ALTER TABLE `Users` MODIFY `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + MODIFY `updated_at` DATETIME(3) NOT NULL, + MODIFY `inactiveDate` DATETIME(6) NULL; + +-- AlterTable +ALTER TABLE `Verifications` MODIFY `created_at` DATETIME(3) NULL DEFAULT CURRENT_TIMESTAMP(3), + MODIFY `updated_at` DATETIME(3) NULL; diff --git a/prisma/migrations/20250115083611_v4/migration.sql b/prisma/migrations/20250115083611_v4/migration.sql new file mode 100644 index 0000000..7fdda50 --- /dev/null +++ b/prisma/migrations/20250115083611_v4/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - A unique constraint covering the columns `[email]` on the table `Users` will be added. If there are existing duplicate values, this will fail. + +*/ +-- CreateIndex +CREATE UNIQUE INDEX `Users_email_key` ON `Users`(`email`); diff --git a/prisma/migrations/migration_lock.toml b/prisma/migrations/migration_lock.toml new file mode 100644 index 0000000..8a21669 --- /dev/null +++ b/prisma/migrations/migration_lock.toml @@ -0,0 +1,3 @@ +# Please do not edit this file manually +# It should be added in your version-control system (e.g., Git) +provider = "mysql" \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 35f0817..a655bd5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -23,12 +23,12 @@ model User { userBadge3_id Int? name String @db.VarChar(10) gender Gender? - email String @db.VarChar(255) + email String @db.VarChar(255) @unique phoneNumber String @db.VarChar(15) password String @db.VarChar(255) - created_at DateTime @db.DateTime(6) - updated_at DateTime @db.DateTime(6) - inactiveDate DateTime @db.DateTime(6) + created_at DateTime @default(now()) + updated_at DateTime @updatedAt + inactiveDate DateTime? @db.DateTime(6) profilePhoto String? @db.VarChar(255) level Level? followerCount Int @@ -38,8 +38,6 @@ model User { userCategory UserCategory? ageGroup AgeGroup? - - challengeLikes ChallengeLike[] comments Comment[] posts Post[] @@ -59,7 +57,6 @@ model User { receivedMessages Message[] @relation("ReceivedMessages") sentMessages Message[] @relation("SentMessages") - @@map("Users") } @@ -118,8 +115,8 @@ model Post { title String? @db.VarChar(50) content String? @db.VarChar(200) anonymous Boolean? - created_at DateTime? @db.DateTime(6) - updated_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) + updated_at DateTime? @updatedAt comments Comment [] postLikes PostLike[] @@ -144,7 +141,7 @@ model Message { sendUser User @relation("SentMessages", fields: [sendUser_id], references: [id]) sendUser_id Int content String? @db.Text - created_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) @@map("Messages") } @@ -163,8 +160,8 @@ model Verification { question Boolean? textUrl String? @db.VarChar(255) verificationStatus VerificationStatus @map("status") - created_at DateTime? @db.DateTime(6) - updated_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) + updated_at DateTime? @updatedAt deadline DateTime? @db.DateTime(6) comments Comment[] @@ -181,7 +178,7 @@ model KickOut { userChallenge UserChallenge @relation(fields: [userChallenge_id], references: [id]) userChallenge_id Int challengeType ChallengeType - created_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) @@map("KickOuts") } @@ -220,9 +217,9 @@ model UserBadge { user_id Int badge Badge @relation(fields: [badge_id], references: [id]) badge_id Int - created_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) obtain Boolean - updated_at DateTime? @db.DateTime(6) + updated_at DateTime? @updatedAt userBadge1 User[] @relation("Badge1") userBadge2 User[] @relation("Badge2") @@ -294,7 +291,7 @@ model Scrap { scrapTarget2 Verification? @relation("ScrapTarget2", fields: [scrapTarget2_id], references: [id]) scrapTarget2_id Int scrapType ScrapType - created_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) @@map("Scraps") } @@ -308,8 +305,8 @@ model TemporaryVerification { challengeType ChallengeType title String? @db.VarChar(20) content String? @db.VarChar(200) - created_at DateTime? @db.DateTime(6) - updated_at DateTime? @db.DateTime(6) + created_at DateTime? @default(now()) + updated_at DateTime? @updatedAt @@map("TemporaryVerifications") } @@ -541,4 +538,4 @@ enum UserCategory { enum BadgeType { category type -} \ No newline at end of file +} diff --git a/prisma/seed.js b/prisma/seed.js new file mode 100644 index 0000000..04b8d3c --- /dev/null +++ b/prisma/seed.js @@ -0,0 +1,114 @@ +import { PrismaClient } from '@prisma/client'; +const prisma = new PrismaClient(); + +const main = async () => { + console.log('Seeding database...'); + + // Users Table + await prisma.user.createMany({ + data: [ + { + name: 'John Doe', + gender: 'male', + email: 'john@example.com', + phoneNumber: '1234567890', + password: 'password123', + profilePhoto: 'https://example.com/profile1.jpg', + level: 'bronze', + followerCount: 10, + followingCount: 5, + points: 100, + job: 'officeWorker', + userCategory: 'exercise', + ageGroup: 'twenty', + }, + { + name: 'Jane Smith', + gender: 'female', + email: 'jane@example.com', + phoneNumber: '0987654321', + password: 'password456', + profilePhoto: 'https://example.com/profile2.jpg', + level: 'silver', + followerCount: 20, + followingCount: 15, + points: 200, + job: 'collegeStudent', + userCategory: 'study', + ageGroup: 'thirty', + }, + ], + }); + + // Keywords Table + await prisma.keyword.createMany({ + data: [ + { name: 'motivation' }, + { name: 'study' }, + { name: 'health' }, + { name: 'productivity' }, + ], + }); + + // Badges Table + await prisma.badge.createMany({ + data: [ + { + name: 'Starter Badge', + icon: 'https://example.com/badge1.png', + description: 'Awarded for starting your first challenge', + type: 'category', + obtainedCount: 100, + profileImage: 'https://example.com/badge1_profile.png', + }, + { + name: 'Achiever Badge', + icon: 'https://example.com/badge2.png', + description: 'Awarded for completing 5 challenges', + type: 'type', + obtainedCount: 50, + profileImage: 'https://example.com/badge2_profile.png', + }, + ], + }); + + // Challenges Table + await prisma.challenge.createMany({ + data: [ + { + owner_id: 1, + name: '๋งค์ผ ์šด๋™', + type: 'basic', + description: 'A challenge to exercise daily for 30 minutes', + challengeImage: 'https://example.com/challenge1.png', + challengeStatus: 'open', + maxParticipants: 50, + verificationType: 'camera', + rule: 'Submit a photo after exercise', + }, + { + owner_id: 2, + name: '๊ฐ™์ด ๊ณต๋ถ€', + type: 'study', + description: 'Study 2 hours every day for a week', + challengeImage: 'https://example.com/challenge2.png', + challengeStatus: 'ongoing', + maxParticipants: 30, + verificationType: 'text', + rule: 'Submit a text summary of what you studied', + }, + ], + }); + + // Other Tables (Add similar logic for other tables as needed) + console.log('Database seeded successfully!'); +}; + +main() + .catch((e) => { + console.error('Error seeding database:', e); + process.exit(1); + }) + .finally(async () => { + await prisma.$disconnect(); + });