Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK-407] 영상관련 도메인 Entity 생성 #13

Merged
merged 3 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
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
46 changes: 46 additions & 0 deletions src/main/java/com/speechpeach/speech/record/entity/Record.java
Original file line number Diff line number Diff line change
@@ -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;
beautiflow marked this conversation as resolved.
Show resolved Hide resolved

@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);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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<YoutubeVideoLike> 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);
}

}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading