diff --git a/src/main/java/nutshell/server/domain/GoogleCalender.java b/src/main/java/nutshell/server/domain/GoogleCalender.java new file mode 100644 index 0000000..fb946a7 --- /dev/null +++ b/src/main/java/nutshell/server/domain/GoogleCalender.java @@ -0,0 +1,39 @@ +package nutshell.server.domain; + +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Entity +@Getter +@NoArgsConstructor(access= AccessLevel.PROTECTED) +public class GoogleCalender { + @Id + @GeneratedValue(strategy= GenerationType.IDENTITY) + private Long id; + + @Column(name = "token", nullable = false, unique = true) + private String token; + + @Column(name = "email", nullable = false, unique = true) + private String email; + + @Column(name = "created_at", nullable = false) + private LocalDateTime createdAt; + + @ManyToOne(targetEntity= User.class, fetch=FetchType.LAZY) + @JoinColumn(name="user_id", nullable = false) + private User user; + + @Builder + public GoogleCalender(String token, String email, User user) { + this.token = token; + this.email = email; + this.user = user; + this.createdAt = LocalDateTime.now(); + } +} diff --git a/src/main/java/nutshell/server/domain/User.java b/src/main/java/nutshell/server/domain/User.java index 6a89829..b36489d 100644 --- a/src/main/java/nutshell/server/domain/User.java +++ b/src/main/java/nutshell/server/domain/User.java @@ -27,9 +27,6 @@ public class User { @Column(name="serial_id", nullable = false, unique = true) private String serialId; - @Column(name="google_token") - private String googleToken; - @Column(name="created_at", nullable = false) private LocalDateTime createdAt; @@ -39,6 +36,9 @@ public class User { @OneToMany(mappedBy="user", fetch=FetchType.LAZY, cascade=CascadeType.ALL) private List tasks; + @OneToMany(mappedBy="user", fetch=FetchType.LAZY, cascade=CascadeType.ALL) + private List googleCalenders; + @Builder public User(String name, String email, String serialId) { this.name = name; @@ -47,9 +47,4 @@ public User(String name, String email, String serialId) { this.createdAt = LocalDateTime.now(); this.updatedAt = LocalDateTime.now(); } - - public void updateGoogleToken(String googleToken) { - this.googleToken = googleToken; - this.updatedAt = LocalDateTime.now(); - } }