Skip to content

[FEAT] 연주 엔티티 구현 - #15

Merged
on1yoneprivate merged 4 commits into
developfrom
feat/#13-playing-entity
Jul 12, 2026
Merged

[FEAT] 연주 엔티티 구현#15
on1yoneprivate merged 4 commits into
developfrom
feat/#13-playing-entity

Conversation

@on1yoneprivate

@on1yoneprivate on1yoneprivate commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📍 개요

연주 및 MIDI 이벤트 엔티티 구현

⛓️‍💥 관련 이슈


🛠️ 작업 내용

  • 연주(Playing) 엔티티 구현
  • 자유 연주 및 백킹트랙 연주 생성 로직 구현
  • MIDI 이벤트(MidiEvent) 엔티티 구현
  • 연주 모드, 연주 상태, MIDI 타입 Enum 추가
  • BPM 및 MIDI 이벤트 입력값 검증 로직 추가
  • 연주 도메인 예외 코드 추가
  • 연주별 MIDI 이벤트 시간순 조회를 위한 복합 인덱스 추가
  • Playing 소프트 삭제 구조 적용

🔥 리뷰 요청 사항

리뷰어가 중점적으로 확인해주었으면 하는 내용을 작성해주세요.

  • Playing 엔티티의 자유 연주 / 백킹트랙 연주 생성 메서드 분리 방식
  • MidiEvent의 playing_id, timestamp_ms 복합 인덱스 설정

✅ 체크리스트

  • 코드 컨벤션을 준수했습니다.
  • 불필요한 코드 및 import를 제거했습니다.
  • 예외 처리를 적용했습니다.
  • 테스트를 완료했습니다.
  • 관련 Issue를 연결했습니다.

📎 참고 사항

  • User 및 BackingTrack 엔티티 연관관계는 추후 설정할 예정
  • BPM 기본값은 120이며, 허용 범위는 50~200
  • MIDI 피치 및 강도 값의 허용 범위는 0~127
  • MIDI 이벤트 타임스탬프는 0 이상의 값만 허용하도록 검증

Summary by CodeRabbit

  • 새로운 기능
    • 자유 연주와 백킹트랙 연주를 지원하는 연주 세션이 추가되었습니다.
    • 연주 모드와 상태(준비, 진행 중, 일시정지, 완료, 자동 종료)를 관리할 수 있습니다.
    • MIDI 노트 온/오프 이벤트와 관련 메트릭(음정, 세기, 시간)을 기록할 수 있습니다.
    • BPM(기본값 적용), 메트로놈, 녹음 정보, 공개 여부를 연주 세션에 설정할 수 있습니다.
  • 버그 수정
    • 사용자/백킹트랙 여부, BPM 및 MIDI 값(음정·세기·타임스탬프) 범위를 검증합니다.
    • 잘못된 입력 시 상세 오류 코드로 빠르게 원인을 확인할 수 있습니다.

@on1yoneprivate on1yoneprivate self-assigned this Jul 11, 2026
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6627bed4-15e3-4a15-bf6c-454f7bbd9ed8

📥 Commits

Reviewing files that changed from the base of the PR and between 2657063 and 8d522a1.

📒 Files selected for processing (1)
  • src/main/java/com/mr/domain/playing/entity/Playing.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/com/mr/domain/playing/entity/Playing.java

📝 Walkthrough

Walkthrough

Playing과 MidiEvent JPA 엔티티를 추가하고, 연주 모드·상태와 MIDI 타입을 정의했습니다. 정적 생성 팩토리와 필수값·범위 검증을 제공하며, 관련 오류 코드를 PlayingErrorStatus로 관리합니다.

Changes

연주 도메인 모델

Layer / File(s) Summary
연주 상태 및 검증 계약
src/main/java/com/mr/domain/playing/entity/enums/*, src/main/java/com/mr/domain/playing/exception/PlayingErrorStatus.java
연주 모드와 상태, MIDI 이벤트 타입, 입력 검증 오류 코드와 메시지를 정의합니다.
Playing 생성 및 검증
src/main/java/com/mr/domain/playing/entity/Playing.java
Playing 필드를 JPA 엔티티로 매핑하고, 자유 연주와 백킹트랙 연주를 생성하며 사용자 ID, BPM, 백킹트랙 ID를 검증합니다.
MidiEvent 생성 및 검증
src/main/java/com/mr/domain/playing/entity/MidiEvent.java
MidiEvent 필드를 JPA 엔티티로 매핑하고, MIDI 입력값의 null 및 범위를 검증하는 정적 생성 팩토리를 추가합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

연주의 문이 열리고
MIDI 음표가 춤추네
READY에서 시작해
검증의 방패 반짝인다
NOTE_ON, NOTE_OFF 흐른다 🎵

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 연주 엔티티 구현이라는 핵심 변경을 짧고 명확하게 잘 요약합니다.
Linked Issues check ✅ Passed #13의 Playing 엔티티 구현 요구를 충족하며, 관련 도메인 타입도 함께 추가되었습니다.
Out of Scope Changes check ✅ Passed 추가된 MIDI/enum/예외 타입은 Playing 구현을 돕는 구성요소로 보이며 명백한 범위 이탈은 없습니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#13-playing-entity

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
src/main/java/com/mr/domain/playing/entity/Playing.java (2)

89-134: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

BPM 기본값 로직을 생성자 쪽으로 모아주세요.

createFreePlaycreateBackingTrack이 각각 bpm != null ? bpm : 120을 중복 계산하고 있고, validateBpmbpm != null && ...로 null을 그대로 통과시킵니다. bpm 컬럼은 nullable = false(Line 43-44)인데, 만약 향후 새 팩토리가 기본값 적용 없이 builder()를 호출하면 this.bpm에 null이 대입되어 영속화 시점에야 제약 위반이 드러나게 됩니다. MidiEvent 쪽 validate 메서드들은 모두 null까지 검증하는 것과 비교하면 일관성도 떨어집니다.

기본값 해석과 null 방어를 validateBpm(또는 생성자) 내부로 옮기면 중복도 없어지고 계약이 더 명확해집니다.

♻️ 제안하는 리팩터
-    private static void validateBpm(Integer bpm) {
-        if (bpm != null && (bpm < 50 || bpm > 200)) {
-            throw new GeneralException(PlayingErrorStatus.INVALID_BPM_RANGE);
-        }
-    }
+    private static final int DEFAULT_BPM = 120;
+
+    private static int resolveBpm(Integer bpm) {
+        int resolved = bpm != null ? bpm : DEFAULT_BPM;
+        if (resolved < 50 || resolved > 200) {
+            throw new GeneralException(PlayingErrorStatus.INVALID_BPM_RANGE);
+        }
+        return resolved;
+    }

그리고 팩토리에서는 .bpm(bpm != null ? bpm : 120) 대신 .bpm(resolveBpm(bpm))처럼 단순화할 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/mr/domain/playing/entity/Playing.java` around lines 89 -
134, BPM 기본값 처리와 null 방어를 Playing의 생성 경로에 일관되게 중앙화하세요. validateBpm 또는 생성자에
resolveBpm 로직을 추가해 null은 120으로 변환하고, 변환된 값이 50~200 범위인지 검증하도록 한 뒤
createFreePlay와 createBackingTrack의 중복 삼항식을 해당 로직 사용으로 교체하세요.

1-1: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

경계값 검증 로직에 대한 단위 테스트를 추가해주세요.

PlayingMidiEvent 모두 이번 PR에서 새로 도입된 핵심 검증 로직(BPM 50200, 필수값, pitch/velocity 0127, timestamp≥0)을 가지고 있지만 두 파일 모두 테스트 코드가 없습니다. 도메인 검증은 회귀에 민감한 영역이라 경계값(예: bpm=49/50/200/201) 위주의 단위 테스트를 지금 추가해두면 이후 리팩터링 안전망이 됩니다.

  • src/main/java/com/mr/domain/playing/entity/Playing.java#L66-135: createFreePlay/createBackingTrack의 BPM 경계값(49,50,200,201), userId null, backingTrackId null 케이스에 대한 단위 테스트를 추가하세요.
  • src/main/java/com/mr/domain/playing/entity/MidiEvent.java#L46-104: create의 pitch/velocity 경계값(-1,0,127,128), timestamp 음수, playing/type null 케이스에 대한 단위 테스트를 추가하세요.

원하시면 두 파일에 대한 JUnit 테스트 스켈레톤을 바로 작성해 드릴 수 있습니다.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/com/mr/domain/playing/entity/Playing.java` at line 1, Playing 및
MidiEvent의 핵심 검증 로직에 경계값 단위 테스트를 추가하세요. Playing 테스트에서는
createFreePlay/createBackingTrack의 BPM 49·50·200·201, userId null,
backingTrackId null을 검증하고, MidiEvent 테스트에서는 create의 pitch·velocity -1·0·127·128,
음수 timestamp, playing/type null을 검증하세요. 각 입력이 기대된 성공 또는 예외 결과를 내는지 JUnit 테스트로
명확히 확인하세요.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/main/java/com/mr/domain/playing/entity/Playing.java`:
- Around line 89-134: BPM 기본값 처리와 null 방어를 Playing의 생성 경로에 일관되게 중앙화하세요.
validateBpm 또는 생성자에 resolveBpm 로직을 추가해 null은 120으로 변환하고, 변환된 값이 50~200 범위인지
검증하도록 한 뒤 createFreePlay와 createBackingTrack의 중복 삼항식을 해당 로직 사용으로 교체하세요.
- Line 1: Playing 및 MidiEvent의 핵심 검증 로직에 경계값 단위 테스트를 추가하세요. Playing 테스트에서는
createFreePlay/createBackingTrack의 BPM 49·50·200·201, userId null,
backingTrackId null을 검증하고, MidiEvent 테스트에서는 create의 pitch·velocity -1·0·127·128,
음수 timestamp, playing/type null을 검증하세요. 각 입력이 기대된 성공 또는 예외 결과를 내는지 JUnit 테스트로
명확히 확인하세요.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ec01cd73-9178-4207-8079-71444bbbf225

📥 Commits

Reviewing files that changed from the base of the PR and between ba406e3 and 2657063.

📒 Files selected for processing (6)
  • src/main/java/com/mr/domain/playing/entity/MidiEvent.java
  • src/main/java/com/mr/domain/playing/entity/Playing.java
  • src/main/java/com/mr/domain/playing/entity/enums/MidiType.java
  • src/main/java/com/mr/domain/playing/entity/enums/PlayingMode.java
  • src/main/java/com/mr/domain/playing/entity/enums/PlayingStatus.java
  • src/main/java/com/mr/domain/playing/exception/PlayingErrorStatus.java

@Getter
@Table(
name = "midi_event",
indexes = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수고하셨습니다.
수정이 필요한 건 아니지만

이런 거 줄바꿈 하는 것도 다같이 맞춰서 하면 좋을 것 같습니다!
한 사람이 짠 코드 처럼요!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오늘 회의 때 논의해 보면 좋겠네요!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 확인했습니다!
논의 후 수정할게요~

@ownue ownue left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private builder와 정적 팩토리 메서드로 생성자를 통일한 게 좋은 것 같아요 👍👍
수고하셨습니다~!

@on1yoneprivate
on1yoneprivate merged commit 444519b into develop Jul 12, 2026
2 checks passed
@on1yoneprivate
on1yoneprivate deleted the feat/#13-playing-entity branch July 24, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ Feature - 연주(Playing) 엔티티 구현

3 participants