-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from DSM-InQ/db-setting
feat: question entity 세팅
- Loading branch information
Showing
9 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/Problem.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
6 changes: 6 additions & 0 deletions
6
src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/ProblemType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package kr.hs.dsm.inq.domain.question.persistence | ||
|
||
enum class ProblemType { | ||
QUESTION, | ||
SET | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSets.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
) |
25 changes: 25 additions & 0 deletions
25
src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/QuestionSolvingHistory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/kr/hs/dsm/inq/domain/question/persistence/SetQuestion.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
7 changes: 7 additions & 0 deletions
7
...ain/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSetsRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<QuestionSets, Long> { | ||
} |
8 changes: 8 additions & 0 deletions
8
.../kr/hs/dsm/inq/domain/question/persistence/repository/QuestionSolvingHistoryRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<QuestionSolvingHistory, Long> { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
...main/kotlin/kr/hs/dsm/inq/domain/question/persistence/repository/SetQuestionRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<SetQuestion, SetQuestionID> { | ||
|
||
} |