diff --git a/src/main/kotlin/com/swm_standard/phote/entity/Member.kt b/src/main/kotlin/com/swm_standard/phote/entity/Member.kt index 3950dba..6d6445d 100644 --- a/src/main/kotlin/com/swm_standard/phote/entity/Member.kt +++ b/src/main/kotlin/com/swm_standard/phote/entity/Member.kt @@ -1,13 +1,19 @@ package com.swm_standard.phote.entity +import jakarta.persistence.CascadeType import jakarta.persistence.Column import jakarta.persistence.Entity import jakarta.persistence.EnumType import jakarta.persistence.Enumerated import jakarta.persistence.Id +import jakarta.persistence.OneToMany +import org.hibernate.annotations.SQLDelete +import org.hibernate.annotations.SQLRestriction import java.util.UUID @Entity +@SQLDelete(sql = "UPDATE question_set SET deleted_at = NOW() WHERE question_set_id = ?") +@SQLRestriction("deleted_at is NULL") data class Member( val name: String, val email: String, @@ -18,4 +24,13 @@ data class Member( @Id @Column(name = "member_uuid", nullable = false, unique = true) val id: UUID = UUID.randomUUID() + + @OneToMany(mappedBy = "member", cascade = [(CascadeType.REMOVE)]) + val questions: List = emptyList() + + @OneToMany(mappedBy = "member", cascade = [(CascadeType.REMOVE)]) + val workbooks: List = emptyList() + + @OneToMany(mappedBy = "member", cascade = [(CascadeType.REMOVE)]) + val exams: List = emptyList() } diff --git a/src/main/kotlin/com/swm_standard/phote/service/MemberService.kt b/src/main/kotlin/com/swm_standard/phote/service/MemberService.kt index faca49e..ed0c262 100644 --- a/src/main/kotlin/com/swm_standard/phote/service/MemberService.kt +++ b/src/main/kotlin/com/swm_standard/phote/service/MemberService.kt @@ -10,9 +10,6 @@ class MemberService( ) { fun deleteMember(memberId: UUID): UUID { memberRepository.deleteById(memberId) - if (memberRepository.existsById(memberId)) { - throw IllegalStateException() - } return memberId }