Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions src/main/java/hello/booktown/domain/User.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package hello.booktown.domain;

import hello.booktown.domain.enums.Difficulty;
import hello.booktown.domain.enums.UserRole;
import jakarta.persistence.*;
import lombok.*;

import java.util.List;

@Entity
@Table(uniqueConstraints = {
@UniqueConstraint(columnNames = {"provider", "providerId"})
Expand Down Expand Up @@ -43,9 +44,24 @@ public User(String email, String provider, String providerId, String username, S

private String introduction;

@OneToMany(mappedBy = "user")
private java.util.List<BookApply> bookApplies;
// 실제 연관관계가 존재하는 엔티티만 남깁니다
@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE, orphanRemoval = true)
private List<BookApply> bookApplies;

@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE, orphanRemoval = true)
private List<Quiz> quizzes;

@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE, orphanRemoval = true)
private List<QuizSubmissionGroup> quizSubmissionGroups;

@OneToMany(mappedBy = "user", cascade = CascadeType.REMOVE, orphanRemoval = true)
private List<BookLike> bookLikes;

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private UserRole role;

// 업데이트 메서드
public void updateIntroduction(String introduction) {
this.introduction = introduction;
}
Expand All @@ -58,10 +74,6 @@ public void updateScore(Long score) {
this.score = score;
}

@Enumerated(EnumType.STRING)
@Column(nullable = false)
private UserRole role;

public void setProfileImage(String imageUrl) {
this.profileImage = imageUrl;
}
Expand Down