|
| 1 | +package com.moplus.moplus_server.domain.problem.domain; |
| 2 | + |
| 3 | +import com.moplus.moplus_server.global.common.BaseEntity; |
| 4 | +import jakarta.persistence.CascadeType; |
| 5 | +import jakarta.persistence.CollectionTable; |
| 6 | +import jakarta.persistence.Column; |
| 7 | +import jakarta.persistence.ElementCollection; |
| 8 | +import jakarta.persistence.Entity; |
| 9 | +import jakarta.persistence.FetchType; |
| 10 | +import jakarta.persistence.GeneratedValue; |
| 11 | +import jakarta.persistence.GenerationType; |
| 12 | +import jakarta.persistence.Id; |
| 13 | +import jakarta.persistence.JoinColumn; |
| 14 | +import jakarta.persistence.OneToMany; |
| 15 | +import java.util.ArrayList; |
| 16 | +import java.util.List; |
| 17 | +import java.util.Set; |
| 18 | +import lombok.Getter; |
| 19 | +import lombok.NoArgsConstructor; |
| 20 | + |
| 21 | +@Getter |
| 22 | +@Entity |
| 23 | +@NoArgsConstructor |
| 24 | +public class Problem extends BaseEntity { |
| 25 | + |
| 26 | + @Id |
| 27 | + @GeneratedValue(strategy = GenerationType.IDENTITY) |
| 28 | + @Column(name = "problem_id") |
| 29 | + Long id; |
| 30 | + |
| 31 | + String practiceTestId; |
| 32 | + int number; |
| 33 | + int answer; |
| 34 | + String comment; |
| 35 | + String mainProblemImageUrl; |
| 36 | + String mainAnalysisImageUrl; |
| 37 | + String readingTipImageUrl; |
| 38 | + String seniorTipImageUrl; |
| 39 | + String prescriptionImageUrl; |
| 40 | + |
| 41 | + @ElementCollection |
| 42 | + @CollectionTable(name = "problem_concept", joinColumns = @JoinColumn(name = "concept_tag_id")) |
| 43 | + Set<Long> conceptTagIds; |
| 44 | + |
| 45 | + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.LAZY) |
| 46 | + @JoinColumn(name = "problem_id") |
| 47 | + private List<ChildProblem> childProblems = new ArrayList<>(); |
| 48 | + |
| 49 | + public Problem(String practiceTestId, int number, int answer, String comment, String mainProblemImageUrl, |
| 50 | + String mainAnalysisImageUrl, String readingTipImageUrl, String seniorTipImageUrl, |
| 51 | + String prescriptionImageUrl, Set<Long> conceptTagIds) { |
| 52 | + this.practiceTestId = practiceTestId; |
| 53 | + this.number = number; |
| 54 | + this.answer = answer; |
| 55 | + this.comment = comment; |
| 56 | + this.mainProblemImageUrl = mainProblemImageUrl; |
| 57 | + this.mainAnalysisImageUrl = mainAnalysisImageUrl; |
| 58 | + this.readingTipImageUrl = readingTipImageUrl; |
| 59 | + this.seniorTipImageUrl = seniorTipImageUrl; |
| 60 | + this.prescriptionImageUrl = prescriptionImageUrl; |
| 61 | + this.conceptTagIds = conceptTagIds; |
| 62 | + } |
| 63 | +} |
0 commit comments