-
Notifications
You must be signed in to change notification settings - Fork 2
[FEAT] 백킹트랙 생성 및 수정 api 구현 #51
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
02aed91
feat: 백킹트랙 생성 API 구현 및 연관관계 매핑 (#33)
rkdehdrbs7885-oss 1be5ed5
Merge remote-tracking branch 'origin/develop' into feat/#33-backingtr…
rkdehdrbs7885-oss 0b11656
refactor: 임시 값 수정 (#33)
rkdehdrbs7885-oss f24495d
refactor: 백킹트랙 생성 로직 개선 및 JSON 타입 매핑 적용 (#33)
rkdehdrbs7885-oss ae56d49
refactor: 코드 레빗 수정_1 (#33)
rkdehdrbs7885-oss 91f6454
refactor: 코드 레빗 수정_2 (#33)
rkdehdrbs7885-oss 61b8e92
feat: 백킹트랙 수정 api 추가 및 dto 조정 (#33)
rkdehdrbs7885-oss fbdf0f1
Merge remote-tracking branch 'origin/develop' into feat/#33-backingtr…
rkdehdrbs7885-oss 551b808
refactor: 코드 레빗 수정_3 (#33)
rkdehdrbs7885-oss 7b00fe4
refactor: 팀 리뷰 수정_1 (#33)
rkdehdrbs7885-oss d1cebf4
feat: 테스트용 코드 추가 (#33)
rkdehdrbs7885-oss 39bdf3d
feat: 코드 순서 범위 검증 추가 (#33)
rkdehdrbs7885-oss ea1fe39
refactor: 코드 레빗 수정_4 (#33)
rkdehdrbs7885-oss 2853c81
Merge remote-tracking branch 'origin/develop' into feat/#33-backingtr…
rkdehdrbs7885-oss 1799ccd
refactor: 로컬 테스트 수정_1 (#33)
rkdehdrbs7885-oss a20a68f
refactor: 팀 리뷰 수정_2 (#33)
rkdehdrbs7885-oss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/com/mr/domain/backingTrack/controller/BackingTrackController.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| package com.mr.domain.backingTrack.controller; | ||
|
|
||
| import com.mr.domain.backingTrack.dto.req.BackingTrackSaveRequestDTO; | ||
| import com.mr.domain.backingTrack.dto.res.BackingTrackCreateResponseDTO; | ||
| import com.mr.domain.backingTrack.dto.res.BackingTrackUpdateResponseDTO; | ||
| import com.mr.domain.backingTrack.service.BackingTrackService; | ||
| import com.mr.global.apipayload.ApiResponse; | ||
| import com.mr.global.security.principal.CustomUserDetails; | ||
| import jakarta.validation.Valid; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
| import org.springframework.web.bind.annotation.PathVariable; | ||
| import org.springframework.web.bind.annotation.PostMapping; | ||
| import org.springframework.web.bind.annotation.PutMapping; | ||
| import org.springframework.web.bind.annotation.RequestBody; | ||
| import org.springframework.web.bind.annotation.RequestMapping; | ||
| import org.springframework.web.bind.annotation.RestController; | ||
|
|
||
| @RestController | ||
| @RequiredArgsConstructor | ||
| @RequestMapping("/api/backing-tracks") | ||
| public class BackingTrackController { | ||
|
|
||
| private final BackingTrackService backingTrackService; | ||
|
|
||
| @PostMapping | ||
| public ApiResponse<BackingTrackCreateResponseDTO.CreateResultDTO> createBackingTrack( | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @Valid @RequestBody BackingTrackSaveRequestDTO.SaveDTO request | ||
| ) { | ||
| BackingTrackCreateResponseDTO.CreateResultDTO result = | ||
| backingTrackService.createBackingTrack(userDetails.getUserId(), request); | ||
|
|
||
| return ApiResponse.onSuccess(result); | ||
| } | ||
|
|
||
| @PutMapping("/{backingTrackId}") | ||
| public ApiResponse<BackingTrackUpdateResponseDTO.UpdateResultDTO> updateBackingTrack( | ||
| @AuthenticationPrincipal CustomUserDetails userDetails, | ||
| @PathVariable Long backingTrackId, | ||
| @Valid @RequestBody BackingTrackSaveRequestDTO.SaveDTO request | ||
| ) { | ||
| Long userId = userDetails.getUserId(); | ||
| BackingTrackUpdateResponseDTO.UpdateResultDTO result = | ||
| backingTrackService.updateBackingTrack(userId, backingTrackId, request); | ||
| return ApiResponse.onSuccess(result); | ||
| } | ||
| } |
77 changes: 77 additions & 0 deletions
77
src/main/java/com/mr/domain/backingTrack/dto/req/BackingTrackSaveRequestDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| package com.mr.domain.backingTrack.dto.req; | ||
|
|
||
| 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 jakarta.validation.Valid; | ||
| import jakarta.validation.constraints.Max; | ||
| import jakarta.validation.constraints.Min; | ||
| import jakarta.validation.constraints.NotBlank; | ||
| import jakarta.validation.constraints.NotEmpty; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Pattern; | ||
| import jakarta.validation.constraints.Size; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| public class BackingTrackSaveRequestDTO { | ||
|
|
||
| public record SaveDTO( | ||
| @NotBlank(message = "백킹트랙 제목은 필수입니다.") | ||
| @Size(max = 50, message = "백킹트랙 제목은 50자 이내여야 합니다.") | ||
| String title, | ||
|
|
||
| @NotBlank(message = "장르는 필수입니다.") | ||
| @Size(max = 50, message = "장르는 50자 이내여야 합니다.") | ||
| String genre, | ||
|
|
||
| @NotBlank(message = "Key 정보는 필수입니다.") | ||
| @Size(max = 20, message = "Key 정보는 20자 이내여야 합니다.") | ||
| String keySignature, | ||
|
|
||
| @NotNull(message = "조성은 필수입니다.") | ||
| ScaleType scaleType, | ||
|
|
||
| @NotBlank(message = "박자는 필수입니다.") | ||
| @Pattern(regexp = "^([1-9]|1[0-6])/(2|4|8|16)$", message = "음악적으로 유효한 박자 형식이어야 합니다. (예: 4/4, 3/4, 6/8)") | ||
| String timeSignature, | ||
|
|
||
| @NotNull(message = "BPM은 필수입니다.") | ||
| @Min(value = 50, message = "BPM은 50 이상이어야 합니다.") | ||
| @Max(value = 200, message = "BPM은 200 이하여야 합니다.") | ||
| Integer bpm, | ||
|
|
||
| @NotNull(message = "재생 시간은 필수입니다.") | ||
| @Min(value = 60, message = "재생 시간은 최소 60초(1분) 이상이어야 합니다.") | ||
| @Max(value = 600, message = "재생 시간은 최대 600초(10분) 이하여야 합니다.") | ||
| Integer playtimeSec, | ||
|
|
||
| @Size(max = 255, message = "오디오 파일 URL은 255자 이내여야 합니다.") | ||
| String audioFileUrl, | ||
|
|
||
| @NotNull(message = "공개 범위는 필수입니다.") | ||
| AccessLevel accessLevel, | ||
|
|
||
| @NotNull(message = "난이도는 필수입니다.") | ||
| Level level, | ||
|
|
||
| @Valid | ||
| @NotEmpty(message = "코드 진행 정보는 필수입니다.") | ||
| List<ChordProgressionDTO> chordProgression | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
|
||
| ) {} | ||
|
|
||
| public record ChordProgressionDTO( | ||
| @NotNull(message = "마디 번호는 필수입니다.") | ||
| @Min(value = 1, message = "마디 번호는 1 이상이어야 합니다.") | ||
| Integer measureNo, | ||
|
|
||
| @NotNull(message = "코드 순서는 필수입니다.") | ||
| @Min(value = 1, message = "코드 순서는 1 이상이어야 합니다.") | ||
| Integer sequenceNo, | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
|
||
|
|
||
| @NotBlank(message = "코드명은 필수입니다.") | ||
| @Size(max = 30, message = "코드명은 30자 이내여야 합니다.") | ||
| String chordName | ||
| ) {} | ||
| } | ||
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mr/domain/backingTrack/dto/res/BackingTrackCreateResponseDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.mr.domain.backingTrack.dto.res; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public class BackingTrackCreateResponseDTO { | ||
|
|
||
| public record CreateResultDTO( | ||
| Long backingTrackId, | ||
| String title, | ||
|
|
||
| // 날짜 포맷 | ||
| @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
| LocalDateTime createdAt | ||
| ) { | ||
| public static CreateResultDTO of(Long backingTrackId, String title, LocalDateTime createdAt) { | ||
| return new CreateResultDTO(backingTrackId, title, createdAt); | ||
| } | ||
| } | ||
| } |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/mr/domain/backingTrack/dto/res/BackingTrackUpdateResponseDTO.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| package com.mr.domain.backingTrack.dto.res; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| public class BackingTrackUpdateResponseDTO { | ||
|
|
||
| public record UpdateResultDTO( | ||
| Long backingTrackId, | ||
| String title, | ||
|
|
||
| // 날짜 포맷 | ||
| @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") | ||
| LocalDateTime updatedAt | ||
| ) { | ||
| public static BackingTrackUpdateResponseDTO.UpdateResultDTO of(Long backingTrackId, String title, LocalDateTime updatedAt) { | ||
| return new BackingTrackUpdateResponseDTO.UpdateResultDTO(backingTrackId, title, updatedAt); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/com/mr/domain/backingTrack/exception/BackingTrackErrorStatus.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| package com.mr.domain.backingTrack.exception; | ||
|
|
||
| import com.mr.global.apipayload.code.BaseCode; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import org.springframework.http.HttpStatus; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public enum BackingTrackErrorStatus implements BaseCode { | ||
|
|
||
| // [400] Validation Errors | ||
|
rkdehdrbs7885-oss marked this conversation as resolved.
|
||
| TITLE_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_01", "백킹트랙 제목은 필수입니다."), | ||
| TITLE_TOO_LONG(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_02", "백킹트랙 제목은 50자 이내여야 합니다."), | ||
| GENRE_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_03", "장르는 필수입니다."), | ||
| UNSUPPORTED_GENRE(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_04", "지원하지 않는 장르입니다."), | ||
| KEY_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_05", "Key 정보는 필수입니다."), | ||
| INVALID_KEY(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_06", "Key 정보가 올바르지 않습니다."), | ||
| SCALE_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_07", "조성은 필수입니다."), | ||
| INVALID_SCALE(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_08", "조성 값이 올바르지 않습니다."), | ||
| TIME_SIGNATURE_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_09", "박자는 필수입니다."), | ||
| INVALID_TIME_SIGNATURE(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_10", "박자 형식이 올바르지 않습니다."), | ||
| BPM_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_11", "BPM은 필수입니다."), | ||
| INVALID_BPM(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_12", "BPM 값이 올바르지 않습니다."), | ||
| PLAYTIME_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_13", "재생 시간은 필수입니다."), | ||
| INVALID_PLAYTIME(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_14", "재생 시간은 60초 이상 600초 이하여야 합니다."), | ||
| ACCESS_LEVEL_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_17", "공개 범위는 필수입니다."), | ||
| INVALID_ACCESS_LEVEL(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_18", "공개 범위 값이 올바르지 않습니다."), | ||
| LEVEL_REQUIRED(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_19", "난이도는 필수입니다."), | ||
| INVALID_LEVEL(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_20", "난이도 값이 올바르지 않습니다."), | ||
| DUPLICATE_CHORD_POSITION(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_21", "동일한 마디(measureNo)와 순서(sequenceNo)를 가진 코드 진행이 중복으로 존재합니다."), | ||
| INVALID_CHORD_SEQUENCE(HttpStatus.BAD_REQUEST, "BACKING_TRACK_400_22", "마디의 허용된 코드 순서 범위를 초과했습니다."), | ||
|
|
||
| // [403] 권한 에러 | ||
| FORBIDDEN_UPDATE(HttpStatus.FORBIDDEN, "BACKING_TRACK_403_01", "백킹트랙 수정 권한이 없습니다."), | ||
|
|
||
| // [404] 리소스 없음 | ||
| BACKING_TRACK_NOT_FOUND(HttpStatus.NOT_FOUND, "BACKING_TRACK_404_01", "존재하지 않는 백킹트랙입니다."), | ||
|
|
||
| // [500] 서버 에러 | ||
| INTERNAL_SERVER_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "BACKING_TRACK_500_01", "백킹트랙 생성 중 서버 오류가 발생했습니다."); | ||
|
|
||
| private final HttpStatus status; | ||
| private final String code; | ||
| private final String message; | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.