Repository navigation
[FEAT] 학습, 백킹트랙, 알림, 구독 도메인 관련 엔티티 구현(#16) #24
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
Changes from 9 commits
dee5145
05a564c
bde4168
ee1fb3c
ce9e331
bb8487b
0c00db6
a558736
d2ad998
cb0769d
218bd51
eb93eb7
9839d8e
4ee86e5
8cdd426
3327c45
36e5199
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| package com.mr.domain.backingTrack.entity; | ||
|
|
||
| import com.mr.domain.backingTrack.entity.enums.AccessLevel; | ||
| import com.mr.domain.backingTrack.entity.enums.Level; | ||
| import com.mr.domain.backingTrack.entity.enums.ScaleType; | ||
| import com.mr.global.entity.BaseTimeDeletedEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Index; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.Table; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @Table( | ||
| name = "backing_track", | ||
| indexes = { | ||
| @Index(name = "idx_bt_genre_play", | ||
| columnList = "genre, play_count"), | ||
| } | ||
| ) | ||
| @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
| public class BackingTrack extends BaseTimeDeletedEntity { | ||
|
|
||
| @Id | ||
| @Column(name = "backing_track_id") | ||
| private Long id; | ||
|
|
||
| // 유저 아이디 | ||
| @Column(name = "user_id", nullable = false) | ||
| private Long userId; | ||
|
Comment on lines
+38
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TrackType 확인해 보면 백킹트랙 엔티티에 당장 반영은 되어 있지 않지만, SYSTEM/USER_AUDIO 이렇게 두 개가 존재하는데 SYSTEM에서 생성된 트랙도 user_id를 저장해야 하나요!? 저장하지 않아도 되면 nullable=false를 삭제해야 할 것 같고, 저장해야 한다면 전에 말했던 것처럼 아예 전체 관리자?(삭제된 유저들 데이터 모으는 용) 계정 id를 넣을 생각이셨던 건지 궁금합니다!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 맞습니다! 지난 회의 때 유저가 계정을 삭제하더라도 데이터를 삭제하지 않고 전체 관리자(또는 탈퇴 처리용) 계정 ID로 변경하여 유지하기로 했습니다!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그럼 SYSTEM이 생성한 트랙은 해당 계정 ID로 반영한다는 말씀이신가요? |
||
|
|
||
| // 학원 아이디 | ||
| @Column(name = "academy_id") | ||
| private Long academyId; | ||
|
Comment on lines
+38
to
+44
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 근데 요거 확인해 보니까
|
||
|
|
||
| // 트랙 이름 | ||
| @Column(name = "title", nullable = false, length = 50) | ||
| private String title; | ||
|
|
||
| // 장르 | ||
| @Column(name = "genre", nullable = false, length = 50) | ||
| private String genre; | ||
|
|
||
| // key | ||
| @Column(name = "key_signature", nullable = false, length = 20) | ||
| private String keySignature; | ||
|
|
||
| // 조성 | ||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "scale_type", nullable = false) | ||
| private ScaleType scaleType; | ||
|
|
||
| // 박자 | ||
| @Column(name = "time", nullable = false, length = 10) | ||
| private String time; | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
Resolved
|
||
|
|
||
| // bpm | ||
| @Column(name = "bpm", nullable = false) | ||
| private Integer bpm; | ||
|
|
||
| // 재생 시간 | ||
| @Column(name = "playtime_sec", nullable = false) | ||
| private Integer playtimeSec; | ||
|
|
||
| // 오디오 파일 | ||
| @Column(name = "audio_file_url", length = 255) | ||
| private String audioFileUrl; | ||
|
|
||
| @Column(name = "midi_file_url", columnDefinition = "JSON") | ||
| private String midiFileUrl; | ||
|
|
||
| // 재생 수 | ||
| @Column(name = "play_count", nullable = false) | ||
| private Integer playCount; | ||
|
|
||
| // 공개 범위 | ||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "access_level", nullable = false, columnDefinition = "ENUM('PRIVATE', 'ACADEMY', 'PUBLIC') DEFAULT 'PRIVATE'") | ||
| private AccessLevel accessLevel; | ||
|
|
||
| // 난이도 | ||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "level", nullable = false, columnDefinition = "ENUM('BASIC', 'MED', 'ADVANCED') DEFAULT 'BASIC'") | ||
| private Level level; | ||
|
ownue marked this conversation as resolved.
Resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package com.mr.domain.backingTrack.entity; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Index; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Table( | ||
| name = "chord_progression", | ||
| indexes = { | ||
| @Index(name = "idx_chord_progression_track_seq", | ||
| columnList = "backing_track_id, sequence_no") | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 코드 진행 순서가 중복될 수 있을 것 같은데... 근데 음... 제가 이건 기획 이해부터가 어려웟어서...... 하나의 sequence에 여러 코드가 동시에 존재하는 걸 표현해야 하는 건지....... 궁금해여
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ui에서 한 마디(measure_no) 안에 4개의 슬롯(sequence_no)이 들어가는 방식입니다. backing_track_id, measure_no, sequence_no 조합에 Unique을 추가하도록 수정하겠습니다! |
||
| ) | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class ChordProgression{ | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "chord_progression_id") | ||
| private Long chordProgressionId; | ||
|
|
||
| // 백킹트랙 아이디 | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "backing_track_id", nullable = false) | ||
| private BackingTrack backingTrack; | ||
|
|
||
| // 코드 순서 | ||
| @Column(name = "sequence_no", nullable = false) | ||
| private Integer sequenceNo; | ||
|
|
||
| // 마디 번호 | ||
| @Column(name = "measure_no", nullable = false) | ||
| private Integer measureNo; | ||
|
|
||
| // 코드명 | ||
| @Column(name = "chord_name", nullable = false, length = 30) | ||
| private String chordName; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.mr.domain.backingTrack.entity.enums; | ||
|
|
||
| public enum AccessLevel { | ||
| PRIVATE, | ||
| ACADEMY, | ||
| PUBLIC | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| package com.mr.domain.backingTrack.entity.enums; | ||
|
|
||
| public enum Level { | ||
| BASIC, | ||
| MED, | ||
| ADVANCED | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.mr.domain.backingTrack.entity.enums; | ||
|
|
||
| public enum ScaleType { | ||
| MAJOR, | ||
| MINOR | ||
| } |
|
ownue marked this conversation as resolved.
Resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.mr.domain.backingTrack.entity.enums; | ||
|
|
||
| public enum TrackType { | ||
| SYSTEM, | ||
| USER_AUDIO | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| package com.mr.domain.learning.entity; | ||
|
|
||
| import com.mr.global.entity.BaseCreatedEntity; | ||
| import jakarta.persistence.CollectionTable; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.ElementCollection; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.FetchType; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.JoinColumn; | ||
| import jakarta.persistence.ManyToOne; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Entity | ||
| @Getter | ||
| @Table( | ||
| name = "chord_example" | ||
| ) | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class ChordExample extends BaseCreatedEntity { | ||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "chord_example_id") | ||
| private Long chordExampleid; | ||
|
|
||
| // 학습 단계 id | ||
| @ManyToOne(fetch = FetchType.LAZY) | ||
| @JoinColumn(name = "learning_step_id", nullable = false) | ||
| private LearningStep learningStep; | ||
|
|
||
| // 코드명 | ||
| @Column(name = "chord_name", nullable = false, length = 100) | ||
| private String chordName; | ||
|
|
||
| // 미디 노트 번호 목록 (chord_example_note 보조 테이블에 매핑) | ||
| @ElementCollection(fetch = FetchType.LAZY) | ||
| @CollectionTable( | ||
| name = "chord_example_note", | ||
| joinColumns = @JoinColumn(name = "chord_example_id") | ||
| ) | ||
| @Column(name = "note_number", nullable = false) | ||
| private List<Integer> noteNumbers; | ||
|
|
||
| // 설명 | ||
| @Column(name = "description", columnDefinition = "TEXT") | ||
| private String description; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| package com.mr.domain.learning.entity; | ||
|
|
||
| import com.mr.domain.learning.entity.enums.LearningCategory; | ||
| import com.mr.domain.learning.entity.enums.LearningDifficulty; | ||
| import com.mr.global.entity.BaseTimeDeletedEntity; | ||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.Entity; | ||
| import jakarta.persistence.EnumType; | ||
| import jakarta.persistence.Enumerated; | ||
| import jakarta.persistence.GeneratedValue; | ||
| import jakarta.persistence.GenerationType; | ||
| import jakarta.persistence.Id; | ||
| import jakarta.persistence.Index; | ||
| import jakarta.persistence.Table; | ||
| import lombok.AccessLevel; | ||
| import lombok.Builder; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @Entity | ||
| @Table( | ||
| name = "learning", | ||
| indexes = { | ||
| @Index(name = "idx_learning_active", | ||
| columnList = "is_active") | ||
| } | ||
| ) | ||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||
| public class Learning extends BaseTimeDeletedEntity { | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
Resolved
|
||
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "learning_id") | ||
| private Long id; | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
Resolved
|
||
|
|
||
| //제목 | ||
| @Column(name = "title", nullable = false, length = 100) | ||
| private String title; | ||
|
|
||
| // 카테고리 | ||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "category", nullable = false, length = 50) | ||
| private LearningCategory category; | ||
|
|
||
| // 난이도 | ||
| @Enumerated(EnumType.STRING) | ||
| @Column(name = "difficulty", nullable = false, length = 50) | ||
| private LearningDifficulty difficulty; | ||
|
|
||
| // 핵심 요약 | ||
| @Column(name = "summary", length = 255) | ||
| private String summary; | ||
|
|
||
| // 이론 설명 | ||
| @Column(name = "content", nullable = false, columnDefinition = "TEXT") | ||
| private String content; | ||
|
|
||
| // 엽습 팁 | ||
| @Column(name = "practice_tip", columnDefinition = "TEXT") | ||
| private String practiceTip; | ||
|
|
||
| // 소요 시간 | ||
| @Column(name = "estimated_minutes") | ||
| private int estimatedMinutes = 0; | ||
|
|
||
| @Column(name = "instrument_type", nullable = false) | ||
| private String instrumentType; | ||
|
|
||
| // 활성 여부 | ||
| @Column(name = "is_active", nullable = false) | ||
| private Boolean isActive = true; | ||
|
|
||
| @Builder(access = AccessLevel.PRIVATE) | ||
| private Learning(String title, String subtitle, LearningCategory category, LearningDifficulty difficulty, | ||
| String summary, String content, String practiceTip, String diagramUrl, Boolean isActive) { | ||
| this.title = title; | ||
| this.category = category != null ? category : LearningCategory.THEORY; | ||
| this.difficulty = difficulty != null ? difficulty : LearningDifficulty.BEGINNER; // Default: BEGINNER | ||
| this.summary = summary; | ||
| this.content = content; | ||
| this.practiceTip = practiceTip; | ||
| this.isActive = isActive != null ? isActive : true; | ||
| } | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
Resolved
|
||
|
|
||
| public static Learning create(String title, String subtitle, LearningCategory category, LearningDifficulty difficulty, | ||
| String summary, String content, String practiceTip, String diagramUrl) { | ||
| return Learning.builder() | ||
| .title(title) | ||
| .subtitle(subtitle) | ||
| .category(category) | ||
| .difficulty(difficulty) | ||
| .summary(summary) | ||
| .content(content) | ||
| .practiceTip(practiceTip) | ||
| .diagramUrl(diagramUrl) | ||
| .isActive(true) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 파라미터에서 isActive를 전달받고 있는데, 빌더에는 항상 true를 넣고 있어 전달값이 사용되지 않는 것 같습니다! 생성 시 항상 활성 상태로 만들 계획이라면 파라미터를 제거하고, 생성 시 상태를 선택할 수 있어야 한다면 .isActive(isActive)로 변경하는 것이 좋을 것 같습니다. |
||
| .build(); | ||
| } | ||
|
|
||
| public void activate() { | ||
| this.isActive = true; | ||
| } | ||
|
|
||
| public void deactivate() { | ||
| this.isActive = false; | ||
| } | ||
|
|
||
| public void updateContent(String title, String subtitle, LearningCategory category, LearningDifficulty difficulty, | ||
| String summary, String content, String practiceTip, String diagramUrl) { | ||
| this.title = title; | ||
| this.category = category; | ||
| this.difficulty = difficulty; | ||
| this.summary = summary; | ||
| this.content = content; | ||
| this.practiceTip = practiceTip; | ||
| } | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
Resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.