diff --git a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java index f7ee473..2cca933 100644 --- a/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java +++ b/backend/src/main/java/com/edufocus/edufocus/board/entity/vo/Board.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.UpdateTimestamp; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; @@ -59,9 +61,9 @@ public class Board { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "lecture_id") + @OnDelete(action = OnDeleteAction.CASCADE) private Lecture lecture; - @OneToMany(mappedBy = "board", cascade = CascadeType.ALL) private List comments; diff --git a/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java b/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java index af797ee..6216f88 100644 --- a/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java +++ b/backend/src/main/java/com/edufocus/edufocus/qna/entity/Qna.java @@ -4,6 +4,8 @@ import com.edufocus.edufocus.lecture.entity.Lecture; import com.edufocus.edufocus.user.model.entity.vo.User; import jakarta.persistence.*; import lombok.*; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import java.util.Date; @@ -13,6 +15,8 @@ import java.util.Date; @Builder @NoArgsConstructor @AllArgsConstructor + + public class Qna { // 연관관계 주인 @@ -50,6 +54,7 @@ public class Qna { @ManyToOne @JoinColumn(name = "lecture_id") + @OnDelete(action = OnDeleteAction.CASCADE) private Lecture lecture; private boolean isMine; diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java index df47ac2..6e5d89a 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/Report.java @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; import lombok.*; import org.hibernate.annotations.CreationTimestamp; +import org.hibernate.annotations.OnDelete; +import org.hibernate.annotations.OnDeleteAction; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -50,10 +52,10 @@ public class Report { @JoinColumn(name = "reportset_id") private ReportSet reportSet; - @OneToMany(mappedBy = "report", cascade = CascadeType.REMOVE) + @OneToMany(mappedBy = "report", cascade = CascadeType.REMOVE) private List answers; - public ReportResponse makeReportResponse(){ + public ReportResponse makeReportResponse() { return ReportResponse.builder() .reportId(id) .name(user.getName()) diff --git a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java index fb293ec..c23547c 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/entity/vo/ReportSet.java @@ -5,10 +5,9 @@ import com.edufocus.edufocus.quiz.entity.QuizSet; import com.edufocus.edufocus.report.entity.dto.ReportSetResponse; import com.fasterxml.jackson.annotation.JsonAutoDetect; import jakarta.persistence.*; +import jakarta.persistence.CascadeType; import lombok.*; -import org.hibernate.annotations.ColumnDefault; -import org.hibernate.annotations.CreationTimestamp; -import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.*; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; @@ -19,7 +18,6 @@ import java.util.List; import java.util.UUID; - @Entity @Getter @Builder @@ -46,6 +44,7 @@ public class ReportSet { @ManyToOne @JoinColumn(name = "lecture_id") + @OnDelete(action = OnDeleteAction.CASCADE) private Lecture lecture; @ManyToOne @@ -60,7 +59,7 @@ public class ReportSet { .build(); } - public long findUserId(){ + public long findUserId() { return lecture.getUser().getId(); } } diff --git a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java index 8ebcaaa..6f27dd6 100644 --- a/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java +++ b/backend/src/main/java/com/edufocus/edufocus/report/service/ReportServiceImpl.java @@ -56,7 +56,7 @@ public class ReportServiceImpl implements ReportService { String inputAnswer = answerInputList.get(idx); boolean isCorrect; Answer answer; - if (quiz.getAnswer().equals(inputAnswer)) { + if (quiz.getAnswer().equalsIgnoreCase(inputAnswer)) { correctCount++; isCorrect = true; } else {