Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] feat: 초기 엔티티 구성 #284

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions backend/src/main/java/reviewme/question/domain/OptionGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package reviewme.question.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "option_group")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class OptionGroup {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "question_id", nullable = false)
private long questionId;

@Column(name = "min_selection_count", nullable = false)
private int minSelectionCount;

@Column(name = "max_selection_count", nullable = false)
private int maxSelectionCount;
}
31 changes: 31 additions & 0 deletions backend/src/main/java/reviewme/question/domain/OptionItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package reviewme.question.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "option_item")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class OptionItem {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "content", nullable = false)
private String content;

@Column(name = "option_group_id", nullable = false)
private long optionGroupId;

@Column(name = "position", nullable = false)
private int position;
}
40 changes: 40 additions & 0 deletions backend/src/main/java/reviewme/question/domain/Question2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package reviewme.question.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "question2")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class Question2 {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "required", nullable = false)
private boolean required;

@Column(name = "question_type", nullable = false)
@Enumerated(EnumType.STRING)
private QuestionType questionType;

@Column(name = "content", nullable = false, length = 1_000)
private String content;

@Column(name = "guideline", nullable = true, length = 1_000)
private String guideline;

@Column(name = "position", nullable = false)
private int position;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package reviewme.question.domain;

public enum QuestionType {
CHECKBOX,
TEXT,
;

}
32 changes: 32 additions & 0 deletions backend/src/main/java/reviewme/review/domain/CheckboxAnswer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package reviewme.review.domain;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "checkbox_answer")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class CheckboxAnswer {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "question_id", nullable = false)
private long questionId;

@ElementCollection
@CollectionTable(name = "selected_option_ids")
private List<Long> selectedOptionIds;
}
40 changes: 40 additions & 0 deletions backend/src/main/java/reviewme/review/domain/Review2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package reviewme.review.domain;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "review2")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class Review2 {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "template_id", nullable = false)
private long templateId;

@Column(name = "review_group_id", nullable = false)
private long reviewGroupId;

@OneToMany(cascade = CascadeType.PERSIST)
@JoinColumn(name = "review_id", nullable = false, updatable = false)
private List<TextAnswer> textAnswers;

@OneToMany(cascade = CascadeType.PERSIST)
@JoinColumn(name = "review_id", nullable = false, updatable = false)
private List<CheckboxAnswer> checkboxAnswers;
}
28 changes: 28 additions & 0 deletions backend/src/main/java/reviewme/review/domain/TextAnswer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package reviewme.review.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "text_answer")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class TextAnswer {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "question_id", nullable = false)
private long questionId;

@Column(name = "text", nullable = false, length = 1_000)
private String text;
}
45 changes: 45 additions & 0 deletions backend/src/main/java/reviewme/template/domain/Section.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package reviewme.template.domain;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.Table;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "section")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class Section {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "visible_type", nullable = false)
@Enumerated(EnumType.STRING)
private VisibleType visibleType;

@ElementCollection
@CollectionTable(name = "question_ids", joinColumns = @JoinColumn(name = "section_id"))
private List<Long> questionIds;

@Column(name = "on_selected_option_id", nullable = true)
private Long onSelectedOptionId;

@Column(name = "header", nullable = false, length = 1_000)
private String header;

@Column(name = "position", nullable = false)
private int position;
}
29 changes: 29 additions & 0 deletions backend/src/main/java/reviewme/template/domain/Template.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package reviewme.template.domain;

import jakarta.persistence.CollectionTable;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.Table;
import java.util.List;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "template")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Getter
public class Template {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ElementCollection
@CollectionTable(name = "section_ids", joinColumns = @JoinColumn(name = "template_id"))
List<Long> sectionIds;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package reviewme.template.domain;

public enum VisibleType {

ALWAYS,
CONDITIONAL,
;
}