diff --git a/README.md b/README.md index 48bc43c..1838682 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](https://github.com/Hrr-HabbitRoutineResult/Hrr_BE/blob/main/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. 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 43bca8d..a655bd5 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -16,24 +16,27 @@ 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 String @db.VarChar(255) - email String @db.VarChar(255) + gender Gender? + 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 Int + level Level? followerCount Int followingCount Int points Int + job Job? + userCategory UserCategory? + ageGroup AgeGroup? challengeLikes ChallengeLike[] comments Comment[] @@ -46,13 +49,14 @@ model User { temporaryVerifications TemporaryVerification[] challenges Challenge[] userChallenges UserChallenge[] + userGoals UserGoal[] + alarm Alarm[] followers Follow[] @relation("FollowerRelation") followings Follow[] @relation("FollowingRelation") receivedMessages Message[] @relation("ReceivedMessages") sentMessages Message[] @relation("SentMessages") - @@map("Users") } @@ -111,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[] @@ -137,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") } @@ -156,8 +160,9 @@ 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[] temporaryVerifications TemporaryVerification[] @@ -173,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") } @@ -184,7 +189,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 +201,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") } @@ -205,11 +217,14 @@ 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? @updatedAt userBadge1 User[] @relation("Badge1") userBadge2 User[] @relation("Badge2") userBadge3 User[] @relation("Badge3") + userBadgeCondtions UserBadgeCondition[] @@map("User_Badge") } @@ -233,7 +248,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]) @@ -276,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") } @@ -290,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") } @@ -342,7 +357,7 @@ model UserChallenge { verifyCount Int? unverifiedCount Int? userChallengeStatus UserChallengeStatus @map("status") - warn Int? + warn Int @default(0) verification Verification[] kickOuts KickOut[] @@ -361,6 +376,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 +498,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 +} diff --git a/prisma/seed.js b/prisma/seed.js index d524c95..04b8d3c 100644 --- a/prisma/seed.js +++ b/prisma/seed.js @@ -1,206 +1,112 @@ 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.'); -} +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(e); + .catch((e) => { + console.error('Error seeding database:', e); process.exit(1); }) .finally(async () => { 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()); 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: 'μ±Œλ¦°μ§€ κΈ€ 인증 μš”μ²­ 데이터' } } };