From 53ee22be19d060bd882b7160273cfce3130c472d Mon Sep 17 00:00:00 2001 From: Jihwan Jung Date: Mon, 22 Apr 2024 21:50:06 +0900 Subject: [PATCH] =?UTF-8?q?#25=20feat:=20quiz=20=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EB=B8=94=20=EC=83=9D=EC=84=B1=20=EB=B0=8F=20rds=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EB=B3=80=EC=88=98=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../capstone/content/domain/Content.java | 4 -- .../project/capstone/quiz/domain/Quiz.java | 41 +++++++++++++++++++ .../capstone/quiz/domain/QuizType.java | 27 ++++++++++++ backend/src/main/resources/application.yml | 8 ++-- 4 files changed, 72 insertions(+), 8 deletions(-) create mode 100644 backend/src/main/java/com/project/capstone/quiz/domain/Quiz.java create mode 100644 backend/src/main/java/com/project/capstone/quiz/domain/QuizType.java diff --git a/backend/src/main/java/com/project/capstone/content/domain/Content.java b/backend/src/main/java/com/project/capstone/content/domain/Content.java index fcddadaf73..d253becc2f 100644 --- a/backend/src/main/java/com/project/capstone/content/domain/Content.java +++ b/backend/src/main/java/com/project/capstone/content/domain/Content.java @@ -21,10 +21,6 @@ public class Content { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String type; - @Column(name = "quiz_type") - private String quizType; - @Column(name = "quiz_answer") - private String quizAnswer; private String title; private String body; private String likes; diff --git a/backend/src/main/java/com/project/capstone/quiz/domain/Quiz.java b/backend/src/main/java/com/project/capstone/quiz/domain/Quiz.java new file mode 100644 index 0000000000..912b2cee1d --- /dev/null +++ b/backend/src/main/java/com/project/capstone/quiz/domain/Quiz.java @@ -0,0 +1,41 @@ +package com.project.capstone.quiz.domain; + +import com.project.capstone.book.domain.Book; +import com.project.capstone.club.domain.Club; +import com.project.capstone.member.domain.Member; +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Entity +@EntityListeners(AuditingEntityListener.class) +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Getter +public class Quiz { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + private QuizType type; + private String description; + private String answer; + private String example1; + private String example2; + private String example3; + private String example4; + + @ManyToOne + private Member member; + + @ManyToOne + private Book book; + + @ManyToOne + private Club club; + +} diff --git a/backend/src/main/java/com/project/capstone/quiz/domain/QuizType.java b/backend/src/main/java/com/project/capstone/quiz/domain/QuizType.java new file mode 100644 index 0000000000..a484b6155c --- /dev/null +++ b/backend/src/main/java/com/project/capstone/quiz/domain/QuizType.java @@ -0,0 +1,27 @@ +package com.project.capstone.quiz.domain; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.project.capstone.club.domain.PublicStatus; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum QuizType { + Multiple_Choice("객관식"), + Short_Answer("단답식"), + OX("OX") + ; + + private final String type; + + @JsonCreator + public static QuizType from(String type) { + for (QuizType quizType : QuizType.values()) { + if (quizType.getType().equals(type)) { + return quizType; + } + } + throw new RuntimeException("잘못된 퀴즈 타입 입니다."); + } +} diff --git a/backend/src/main/resources/application.yml b/backend/src/main/resources/application.yml index 96d105d2a2..98c1b8ba6c 100644 --- a/backend/src/main/resources/application.yml +++ b/backend/src/main/resources/application.yml @@ -1,9 +1,9 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://localhost:3306/bm?serverTimezone=UTC&characterEncoding=UTF-8 - username: root - password: 12345678 + url: jdbc:mysql://${DB_ENDPOINT}:${DB_PORT}/${DB_NAME}?serverTimezone=UTC&characterEncoding=UTF-8 + username: ${DB_USERNAME} + password: ${DB_PASSWORD} jpa: hibernate: @@ -15,4 +15,4 @@ spring: mode: always jwt: - secret: gDpXHGuTSnwn6IkHoQE0TyrHT4qGDsbAm6L21qSbzUe8s/Nvo2JsiJyawX8fvUD6 Nh4CdIeQxAqnAzysgk+nUw== \ No newline at end of file + secret: ${JWT_SECRET} \ No newline at end of file