feat: on delete 설정
This commit is contained in:
parent
3027afd059
commit
f628bbbd00
@ -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
|
||||
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
public class Qna {
|
||||
|
||||
// 연관관계 주인
|
||||
|
@ -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;
|
||||
|
||||
@ -22,6 +24,7 @@ import java.util.List;
|
||||
@Builder
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
public class Report {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@ -50,10 +53,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<Answer> answers;
|
||||
|
||||
public ReportResponse makeReportResponse(){
|
||||
public ReportResponse makeReportResponse() {
|
||||
return ReportResponse.builder()
|
||||
.reportId(id)
|
||||
.name(user.getName())
|
||||
|
@ -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
|
||||
@ -27,6 +25,7 @@ import java.util.UUID;
|
||||
@AllArgsConstructor
|
||||
@EntityListeners(AuditingEntityListener.class)
|
||||
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
|
||||
@OnDelete(action = OnDeleteAction.CASCADE)
|
||||
public class ReportSet {
|
||||
@Id
|
||||
@GeneratedValue(generator = "UUID")
|
||||
@ -60,7 +59,7 @@ public class ReportSet {
|
||||
.build();
|
||||
}
|
||||
|
||||
public long findUserId(){
|
||||
public long findUserId() {
|
||||
return lecture.getUser().getId();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user