Skip to content

Commit

Permalink
#25 feat: quiz 테이블 생성 및 rds 환경변수 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
wjdwlghks committed Apr 22, 2024
1 parent d4eb1d8 commit 53ee22b
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
41 changes: 41 additions & 0 deletions backend/src/main/java/com/project/capstone/quiz/domain/Quiz.java
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
@@ -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("잘못된 퀴즈 타입 입니다.");
}
}
8 changes: 4 additions & 4 deletions backend/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -15,4 +15,4 @@ spring:
mode: always

jwt:
secret: gDpXHGuTSnwn6IkHoQE0TyrHT4qGDsbAm6L21qSbzUe8s/Nvo2JsiJyawX8fvUD6 Nh4CdIeQxAqnAzysgk+nUw==
secret: ${JWT_SECRET}

0 comments on commit 53ee22b

Please sign in to comment.