Skip to content

Commit

Permalink
⚡ [feat] #12 GoogleCalender 엔티티 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
minwoo0419 committed Jul 5, 2024
1 parent 860ded9 commit 1801494
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
39 changes: 39 additions & 0 deletions src/main/java/nutshell/server/domain/GoogleCalender.java
Original file line number Diff line number Diff line change
@@ -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)
private String token;

@Column(name = "email", nullable = false)
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();
}
}
11 changes: 3 additions & 8 deletions src/main/java/nutshell/server/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public class User {
@Column(name="serial_id", nullable = false)
private String serialId;

@Column(name="google_token")
private String googleToken;

@Column(name="created_at", nullable = false)
private LocalDateTime createdAt;

Expand All @@ -39,6 +36,9 @@ public class User {
@OneToMany(mappedBy="user", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
private List<Task> tasks;

@OneToMany(mappedBy="user", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
private List<GoogleCalender> googleCalenders;

@Builder
public User(String name, String email, String serialId) {
this.name = name;
Expand All @@ -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();
}
}

0 comments on commit 1801494

Please sign in to comment.