diff --git a/src/main/java/com/speechpeach/speech/record/entity/Record.java b/src/main/java/com/speechpeach/speech/record/entity/Record.java new file mode 100644 index 0000000..e754871 --- /dev/null +++ b/src/main/java/com/speechpeach/speech/record/entity/Record.java @@ -0,0 +1,46 @@ +package com.speechpeach.speech.record.entity; + + +import com.speechpeach.speech.global.entity.BaseEntity; +import com.speechpeach.speech.user.entity.User; +import com.speechpeach.speech.youtubeVideo.entity.YoutubeVideo; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "records") +public class Record extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long recordId; + + @Column(name = "record_title", nullable = false) + private String title; + + @Column(name = "record_content_url", nullable = false) + private String contentUrl; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "youtube_video_id") + private YoutubeVideo youtubeVideo; + + private Record(String title, String contentUrl, User user, YoutubeVideo youtubeVideo) { + this.title = title; + this.contentUrl = contentUrl; + this.user = user; + this.youtubeVideo = youtubeVideo; + } + + public static Record of(String recordTitle, String recordContentUrl, User user, YoutubeVideo youtubeVideo) { + return new Record(recordTitle, recordContentUrl, user, youtubeVideo); + } +} diff --git a/src/main/java/com/speechpeach/speech/videoScript/entity/VideoScript.java b/src/main/java/com/speechpeach/speech/videoScript/entity/VideoScript.java new file mode 100644 index 0000000..e7878aa --- /dev/null +++ b/src/main/java/com/speechpeach/speech/videoScript/entity/VideoScript.java @@ -0,0 +1,58 @@ +package com.speechpeach.speech.videoScript.entity; + +import com.speechpeach.speech.global.entity.BaseEntity; +import com.speechpeach.speech.user.entity.User; +import com.speechpeach.speech.youtubeVideo.entity.YoutubeVideo; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "video_scripts") +public class VideoScript extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long videoScriptId; + + @Column(name = "video_script_title", nullable = false) + private String title; + + /* + @TODO + null이 허용되는 컬럼에 기본값 생각해서 추가 로직 구현 + */ + + @Column(name = "video_script_highlight", columnDefinition = "TEXT", length = 500) + private String highlight; + + @Column(name = "video_script_slash", columnDefinition = "TEXT", length = 500) + private String slash; + + @Column(name = "video_script_color", columnDefinition = "TEXT", length = 500) + private String color; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "youtube_video_id") + private YoutubeVideo youtubeVideo; + + private VideoScript(String title, String highlight, String slash, String color, User user, YoutubeVideo youtubeVideo) { + this.title = title; + this.highlight = highlight; + this.slash = slash; + this.color = color; + this.user = user; + this.youtubeVideo = youtubeVideo; + } + + public static VideoScript of(String videoScriptTitle, String videoScriptHighlight, String videoScriptSlash, String videoScriptColor, User user, YoutubeVideo youtubeVideo){ + return new VideoScript(videoScriptTitle, videoScriptHighlight, videoScriptSlash, videoScriptColor, user, youtubeVideo); + } +} diff --git a/src/main/java/com/speechpeach/speech/youtubeVideo/entity/YoutubeVideo.java b/src/main/java/com/speechpeach/speech/youtubeVideo/entity/YoutubeVideo.java new file mode 100644 index 0000000..c2ee4a0 --- /dev/null +++ b/src/main/java/com/speechpeach/speech/youtubeVideo/entity/YoutubeVideo.java @@ -0,0 +1,51 @@ +package com.speechpeach.speech.youtubeVideo.entity; + +import com.speechpeach.speech.global.entity.BaseEntity; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +import static jakarta.persistence.CascadeType.PERSIST; + +@Getter +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "youtube_videos") +public class YoutubeVideo extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long youtubeVideoId; + + @Column(name = "youtube_video_request_id", nullable = false) + private String requestId; + + @Column(name = "youtube_video_channel_title", nullable = false) + private String channelTitle; + + @Column(name = "youtube_video_title", nullable = false) + private String title; + + @Column(name = "youtube_video_publishedat", nullable = false) + private LocalDateTime publishedAt; + + @OneToMany(mappedBy = "youtubeVideo", cascade = PERSIST, orphanRemoval = true) + private List youtubeVideoLikes = new ArrayList<>(); + + private YoutubeVideo(String requestId, String channelTitle, String title, LocalDateTime publishedAt) { + this.requestId = requestId; + this.channelTitle = channelTitle; + this.title = title; + this.publishedAt = publishedAt; + } + + public static YoutubeVideo of(String youtubeVideoRequestId, String youtubeVideoChannelTitle, String youtubeVideoTitle, LocalDateTime youtubeVideoPublishedAt) { + return new YoutubeVideo(youtubeVideoRequestId, youtubeVideoChannelTitle, youtubeVideoTitle, youtubeVideoPublishedAt); + } + +} diff --git a/src/main/java/com/speechpeach/speech/youtubeVideo/entity/YoutubeVideoLike.java b/src/main/java/com/speechpeach/speech/youtubeVideo/entity/YoutubeVideoLike.java new file mode 100644 index 0000000..422bea3 --- /dev/null +++ b/src/main/java/com/speechpeach/speech/youtubeVideo/entity/YoutubeVideoLike.java @@ -0,0 +1,36 @@ +package com.speechpeach.speech.youtubeVideo.entity; + +import com.speechpeach.speech.global.entity.BaseEntity; +import com.speechpeach.speech.user.entity.User; +import jakarta.persistence.*; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name="likes") +public class YoutubeVideoLike extends BaseEntity { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long likeId; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "youtube_video_id") + private YoutubeVideo youtubeVideo; + + private YoutubeVideoLike(User user, YoutubeVideo youtubeVideo){ + this.user = user; + this.youtubeVideo = youtubeVideo; + } + + public static YoutubeVideoLike of(User user, YoutubeVideo youtubeVideo){ + return new YoutubeVideoLike(user, youtubeVideo); + } +}