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

[Release] 리뷰미 v1.1.3 배포 #786

Merged
merged 1 commit into from
Oct 8, 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.review.domain.abstraction;
package reviewme.review.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package reviewme.review.domain;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
Expand All @@ -18,31 +14,21 @@
import reviewme.review.domain.exception.QuestionNotAnsweredException;

@Entity
@Table(name = "checkbox_answer")
@Table(name = "new_checkbox_answer")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(of = "id")
@EqualsAndHashCode(callSuper = true)
@Getter
public class CheckboxAnswer {

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

@Column(name = "review_id", nullable = false, insertable = false, updatable = false)
private long reviewId;

@Column(name = "question_id", nullable = false)
private long questionId;
public class CheckboxAnswer extends Answer {

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@JoinColumn(name = "checkbox_answer_id", nullable = false, updatable = false)
private List<CheckBoxAnswerSelectedOption> selectedOptionIds;
private List<CheckboxAnswerSelectedOption> selectedOptionIds;

public CheckboxAnswer(long questionId, List<Long> selectedOptionIds) {
validateSelectedOptionIds(questionId, selectedOptionIds);
this.questionId = questionId;
this.selectedOptionIds = selectedOptionIds.stream()
.map(CheckBoxAnswerSelectedOption::new)
.map(CheckboxAnswerSelectedOption::new)
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package reviewme.review.domain.abstraction;
package reviewme.review.domain;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
Expand All @@ -16,7 +16,7 @@
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(of = "id")
@Getter
public class NewCheckboxAnswerSelectedOption {
public class CheckboxAnswerSelectedOption {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
Expand All @@ -28,7 +28,7 @@ public class NewCheckboxAnswerSelectedOption {
@Column(name = "selected_option_id", nullable = false)
private long selectedOptionId;

public NewCheckboxAnswerSelectedOption(long selectedOptionId) {
public CheckboxAnswerSelectedOption(long selectedOptionId) {
this.selectedOptionId = selectedOptionId;
}
}
34 changes: 13 additions & 21 deletions backend/src/main/java/reviewme/review/domain/Review.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.AccessLevel;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Table(name = "review")
@Table(name = "new_review")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(of = "id")
@Getter
Expand All @@ -40,42 +39,35 @@ public class Review {

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

@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.PERSIST)
@JoinColumn(name = "review_id", nullable = false, updatable = false)
private List<CheckboxAnswer> checkboxAnswers;
private List<Answer> answers;

@Column(name = "created_at", nullable = false)
private LocalDateTime createdAt;

public Review(long templateId, long reviewGroupId,
List<TextAnswer> textAnswers, List<CheckboxAnswer> checkboxAnswers) {
public Review(long templateId, long reviewGroupId, List<Answer> answers) {
this.templateId = templateId;
this.reviewGroupId = reviewGroupId;
this.textAnswers = textAnswers;
this.checkboxAnswers = checkboxAnswers;
this.answers = answers;
this.createdAt = LocalDateTime.now();
}

public Set<Long> getAnsweredQuestionIds() {
return Stream.concat(
textAnswers.stream().map(TextAnswer::getQuestionId),
checkboxAnswers.stream().map(CheckboxAnswer::getQuestionId)
).collect(Collectors.toSet());
}

public Set<Long> getAllCheckBoxOptionIds() {
return checkboxAnswers.stream()
.flatMap(answer -> answer.getSelectedOptionIds().stream())
.map(CheckBoxAnswerSelectedOption::getSelectedOptionId)
return answers.stream()
.map(Answer::getQuestionId)
.collect(Collectors.toSet());
}

public boolean hasAnsweredQuestion(long questionId) {
return getAnsweredQuestionIds().contains(questionId);
}

public <T extends Answer> List<T> getAnswersByType(Class<T> clazz) {
return answers.stream()
.filter(clazz::isInstance)
.map(clazz::cast)
.toList();
}

public LocalDate getCreatedDate() {
return createdAt.toLocalDate();
}
Expand Down
16 changes: 3 additions & 13 deletions backend/src/main/java/reviewme/review/domain/TextAnswer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

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.EqualsAndHashCode;
Expand All @@ -13,18 +10,11 @@
import reviewme.review.domain.exception.QuestionNotAnsweredException;

@Entity
@Table(name = "text_answer")
@Table(name = "new_text_answer")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@EqualsAndHashCode(of = "id")
@EqualsAndHashCode(callSuper = true)
@Getter
public class TextAnswer {

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

@Column(name = "question_id", nullable = false)
private long questionId;
public class TextAnswer extends Answer {

@Column(name = "content", nullable = false, length = 5000)
private String content;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading