diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Problem.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Problem.kt new file mode 100644 index 0000000..9b302ad --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Problem.kt @@ -0,0 +1,15 @@ +package kr.hs.dsm.inq.domain.question.persistence + +import javax.persistence.* + +@Table(name = "tbl_problem") +@Entity +data class Problem ( + @Id + @Column(columnDefinition = "BIGINT", nullable = false) + val id: Long = 0L, + + @Column(columnDefinition = "VARCHAR(30)", nullable = false) + @Enumerated(EnumType.STRING) + val type: ProblemType +) diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/ProblemType.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/ProblemType.kt new file mode 100644 index 0000000..6fd8b37 --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/ProblemType.kt @@ -0,0 +1,6 @@ +package kr.hs.dsm.inq.domain.question.persistence + +enum class ProblemType { + QUESTION, + SET +} \ No newline at end of file diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSets.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSets.kt new file mode 100644 index 0000000..1b55266 --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSets.kt @@ -0,0 +1,33 @@ +package kr.hs.dsm.inq.domain.question.persistence + +import java.time.LocalDateTime +import javax.persistence.* + +@Table(name = "tbl_question_set") +@Entity() +class QuestionSets ( + @Id + @Column(columnDefinition = "BIGINT", nullable = false) + @GeneratedValue(strategy = GenerationType.IDENTITY) + var id: Long = 0L, + + @Column(columnDefinition = "VARCHAR(30)", nullable = false) + var name: String, + + @Column(columnDefinition = "VARCHAR(1000)", nullable = false) + var description: String, + + @Column(columnDefinition = "DATETIME(6)", nullable = false, updatable = false) + var createdAt: LocalDateTime = LocalDateTime.now(), + + @Column(columnDefinition = "INT", nullable = false) + var answerCount: Int, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id", columnDefinition = "BIGINT",nullable = false) + var postId: Post, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "problem_id", columnDefinition = "BITINT", nullable = false) + var problemId: Problem, +) \ No newline at end of file diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSolvingHistory.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSolvingHistory.kt new file mode 100644 index 0000000..b1264a8 --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSolvingHistory.kt @@ -0,0 +1,25 @@ +package kr.hs.dsm.inq.domain.question.persistence + +import kr.hs.dsm.inq.domain.user.persistence.User +import java.io.Serializable +import java.time.LocalDateTime +import java.util.Date +import javax.persistence.* + +@Table(name = "tbl_question_solving_history") +@Entity +class QuestionSolvingHistory ( + @Id + var id: Long, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", columnDefinition = "BIGINT", nullable = false) + var userId: User, + + @Column(columnDefinition = "DATETIME(6)", nullable = false) + var solvedAt: LocalDateTime = LocalDateTime.now(), + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "problem", columnDefinition = "BIGINT", nullable = false) + var problem: Problem +) diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Questions.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Questions.kt index 2d48c16..2cf0141 100644 --- a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Questions.kt +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Questions.kt @@ -43,6 +43,10 @@ data class Questions( @JoinColumn(name = "author_id", columnDefinition = "BIGINT", nullable = false) var author: User, + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "problem_id", columnDefinition = "BIGINT", nullable = false) + var problem: Problem, + @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") val createdAt: LocalDateTime = LocalDateTime.now() diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/SetQuestion.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/SetQuestion.kt new file mode 100644 index 0000000..82a3aff --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/SetQuestion.kt @@ -0,0 +1,32 @@ +package kr.hs.dsm.inq.domain.question.persistence + +import java.io.Serializable +import javax.persistence.* + +@Table(name = "tbl_set_question") +@Entity +class SetQuestion ( + @EmbeddedId + val id: SetQuestionID, + + @MapsId("setId") + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "set_id", columnDefinition = "BIGINT", nullable = false) + var setId: QuestionSets, + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "question_id", columnDefinition = "BIGINT", nullable = false) + var questionId: Questions, + + @Column(columnDefinition = "INT", nullable = false) + var index: Int, +) + +@Embeddable +data class SetQuestionID ( + @Column + val setId: Long, + + @Column + val questionId: Long +) : Serializable \ No newline at end of file diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt new file mode 100644 index 0000000..e85b2a4 --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt @@ -0,0 +1,7 @@ +package kr.hs.dsm.inq.domain.question.persistence.repository + +import kr.hs.dsm.inq.domain.question.persistence.QuestionSets +import org.springframework.data.repository.CrudRepository + +interface QuestionSetsRepository : CrudRepository { +} \ No newline at end of file diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSolvingHistoryRepository.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSolvingHistoryRepository.kt new file mode 100644 index 0000000..362975b --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSolvingHistoryRepository.kt @@ -0,0 +1,8 @@ +package kr.hs.dsm.inq.domain.question.persistence.repository + +import kr.hs.dsm.inq.domain.question.persistence.QuestionSolvingHistory +import org.springframework.data.repository.CrudRepository + +interface QuestionSolvingHistoryRepository: CrudRepository { + +} \ No newline at end of file diff --git a/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/SetQuestionRepository.kt b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/SetQuestionRepository.kt new file mode 100644 index 0000000..cb11d84 --- /dev/null +++ b/src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/SetQuestionRepository.kt @@ -0,0 +1,9 @@ +package kr.hs.dsm.inq.domain.question.persistence.repository + +import kr.hs.dsm.inq.domain.question.persistence.SetQuestion +import kr.hs.dsm.inq.domain.question.persistence.SetQuestionID +import org.springframework.data.repository.CrudRepository + +interface SetQuestionRepository : CrudRepository { + +} \ No newline at end of file