Skip to content

Commit

Permalink
Refactor : Remove Column Annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-GyeongSik committed Dec 12, 2023
1 parent d008701 commit 881da7b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@ public class ChapterEntity {
private Long chapterId;

@ManyToOne
@JoinColumn(name = "video_id", nullable = false)
@JoinColumn(name = "video_id")
private VideoEntity video;

@Column(nullable = false)
private int startTime;

@Column(nullable = false)
private int duration;

@OneToOne
@JoinColumn(name = "summary_id", nullable = false)
@JoinColumn(name = "summary_id")
private SummaryEntity summary;
}
11 changes: 2 additions & 9 deletions src/main/java/com/m9d/sroom/common/entity/jpa/LectureEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,21 @@ public class LectureEntity {
private Long lectureId;

@ManyToOne
@JoinColumn(name = "member_id", nullable = false)
@JoinColumn(name = "member_id")
private MemberEntity member;

@ManyToOne
@JoinColumn(name = "course_id", nullable = false)
@JoinColumn(name = "course_id")
private CourseEntity course;

//source_id의 경우 두 테이블(video, playlist) 모두 매핑되어야 하는데 이게 불가능해서 따로 연관관계를 설정하지 않았습니다.
@Column(nullable = true)
private Long sourceId;

@Column(nullable = false)
private Boolean playlist;

@Column(nullable = false)
@ColumnDefault("0")
private Integer lectureIndex;

@Column(nullable = false)
@ColumnDefault("false")
private Boolean reviewed;

@Column(nullable = false)
private String channel;
}
19 changes: 2 additions & 17 deletions src/main/java/com/m9d/sroom/common/entity/jpa/PlaylistEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name="PLAYLIST")
Expand All @@ -15,48 +17,31 @@ public class PlaylistEntity {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long playlistId;

@Column(nullable = false, unique = true)
private String playlistCode;

@Column(nullable = false)
private String channel;

@Column(nullable = false)
private String title;

@Column(nullable = true)
private Integer duration;

@Column(nullable = true)
private String description;

@Column(nullable = false)
private Timestamp publishedAt;

@Column(nullable = false)
private Integer videoCount;

@Column(nullable = false)
@ColumnDefault("0")
private Integer accumulatedRating;

@Column(nullable = true)
@ColumnDefault("false")
private Boolean available;

@Column(nullable = false)
@ColumnDefault("0")
private Integer reviewCount;

@Column(nullable = false)
private String thumbnail;

@Column(nullable = false)
@CreationTimestamp
@UpdateTimestamp
private Timestamp updatedAt;

@Column(nullable = false)
@ColumnDefault("0")
private Float averageRating;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ public class PlaylistVideoEntity {
private Long playlistVideoId;

@ManyToOne
@JoinColumn(name = "playlist_id", nullable = false)
@JoinColumn(name = "playlist_id")
private PlaylistEntity playlist;

@ManyToOne
@JoinColumn(name = "video_id", nullable = false)
@JoinColumn(name = "video_id")
private VideoEntity video;

@Column(nullable = false)
private Integer videoIndex;
}
12 changes: 2 additions & 10 deletions src/main/java/com/m9d/sroom/common/entity/jpa/QuizEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,18 @@ public class QuizEntity {
private Long quizId;

@ManyToOne
@JoinColumn(name = "video_id", nullable = false)
@JoinColumn(name = "video_id")
private VideoEntity video;

@Column(nullable = false)
private int type;

@Column(nullable = false)
private String question;

@Column(nullable = true)
private String subjectiveAnswer;

@Column(nullable = true)
private Integer choiceAnswer;

@Column(nullable = false)
@ColumnDefault("0")
private Integer positiveFeedbackCount;

@Column(nullable = false)
@ColumnDefault("0")
private Integer negativeFeedbackCount;
private Integer negativeFeedbackCount;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@ public class QuizOptionEntity {


@ManyToOne
@JoinColumn(name = "quiz_id", nullable = false)
@JoinColumn(name = "quiz_id")
private QuizEntity quiz;


@Column(nullable = false)
private String optionText;

@Column(nullable = false)
private int optionIndex;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,18 @@ public class SummaryEntity {
private Long summaryId;

@OneToOne
@JoinColumn(name = "video_id", nullable = false)
@JoinColumn(name = "video_id")
private VideoEntity video;

@Column(nullable = false)
private String content;

@Column(nullable = false)
@CreationTimestamp
@UpdateTimestamp
private Timestamp updatedAt;

@Column(nullable = false)
@ColumnDefault("false")
private boolean modified;

@Column(nullable = false)
@ColumnDefault("0")
private Integer positiveFeedbackCount;

@Column(nullable = false)
@ColumnDefault("0")
private Integer negativeFeedbackCount;
}
28 changes: 1 addition & 27 deletions src/main/java/com/m9d/sroom/common/entity/jpa/VideoEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,73 +15,47 @@ public class VideoEntity {
@GeneratedValue(strategy = GenerationType.AUTO)
private Long videoId;

@Column(nullable = false, unique = true)
private String videoCode;

@Column(nullable = false)
private String title;

@Column(nullable = false)
private String channel;

@Column(nullable = true)
private String description;

@Column(nullable = false)
private int duration;

@Column(nullable = false)
private boolean playlist;

@Column(nullable = true)
private Long viewCount;

@Column(nullable = false)
private Timestamp publishedAt;

@Column(nullable = false)
@ColumnDefault("0")
private int accumulatedRating;

@Column(nullable = false)
@ColumnDefault("0")
private int reviewCount;

@Column(nullable = false)
private String thumbnail;

@Column(nullable = true)
private String language;

@Column(nullable = false)
private String license;

@Column(nullable = false)
@CreationTimestamp
@UpdateTimestamp
private Timestamp updatedAt;

@Column(nullable = false)
@ColumnDefault("0")
private boolean membership;

@OneToOne
@JoinColumn(name = "summary_id", nullable = true)
@JoinColumn(name = "summary_id")
private SummaryEntity summary;

@Column(nullable = false)
@ColumnDefault("1")
private boolean available;

@Column(nullable = true)
@ColumnDefault("0")
private boolean chapterUse;

@Column(nullable = false)
@ColumnDefault("-2")
private Integer materialStatus;

@Column(nullable = false)
@ColumnDefault("0")
private Float averageRating;
}

0 comments on commit 881da7b

Please sign in to comment.