Skip to content

Commit

Permalink
[Release] 리뷰미 v1.1.3 배포
Browse files Browse the repository at this point in the history
[Release] 리뷰미 v1.1.3 배포
  • Loading branch information
donghoony authored Oct 8, 2024
2 parents 722c603 + 69aad91 commit c1dd036
Show file tree
Hide file tree
Showing 58 changed files with 268 additions and 1,467 deletions.
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.

24 changes: 5 additions & 19 deletions backend/src/main/java/reviewme/review/domain/CheckboxAnswer.java
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

0 comments on commit c1dd036

Please sign in to comment.