-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* refactor: 중복 코드 메서드 호출로 변경 * refactor: PartLength 가 5초 이상 15초 이하의 값을 가질 수 있도록 리팩터링 - PartLength 를 enum 에서 class 로 변경 * feat: MemberPart 엔티티 추가 * fix: legacy_length 를 nullable 하게 변경 * feat: MemberPart 등록 기능 추가 * feat: MemberPart 삭제 기능 추가 * feat: 마이페이지에서 멤버파트 조회하는 기능 추가 * refactor: 시큐리티 최신버전 동기화 * feat: 노래 응답에 MemberPart 추가 * docs: swagger 명세 추가 * feat: 마이페이지 내 마이파트 조회 swagger 추가 * test: 불필요한 코드 제거 및 필드 변수 사용 * config: dev 데이터 유지하도록 설정 * fix: schema.sql 스키마 변경 * config: init mode never 로 변경 * fix: voting_song_part length 타입 변경 * refactor: 패키지 이름 변경 * feat: 노래 단일 조회 API 추가 * fix: 사용되지 않는 API deprecate 설정 * style: 공백 추가 * refactor: 내 파트 응답 속성 변경 * refactor: 멤버 파트 응답 속성 이름 변경 * fix: 해당 노래에 MemberPart 가 이미 등록되어 있으면 에러 던지도록 수정 * refactor: 마이페이지 내 파트 응답에 노래 비디오 id 추가 * fix: 파트 응답 순서 수정 --------- Co-authored-by: seokhwan-an <[email protected]>
- Loading branch information
1 parent
49b2472
commit 622afd4
Showing
62 changed files
with
1,756 additions
and
317 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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
71 changes: 71 additions & 0 deletions
71
backend/src/main/java/shook/shook/member_part/application/MemberPartService.java
This file contains 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,71 @@ | ||
package shook.shook.member_part.application; | ||
|
||
import java.util.Map; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import shook.shook.auth.exception.AuthorizationException; | ||
import shook.shook.member.domain.Member; | ||
import shook.shook.member.domain.repository.MemberRepository; | ||
import shook.shook.member.exception.MemberException; | ||
import shook.shook.member_part.application.dto.MemberPartRegisterRequest; | ||
import shook.shook.member_part.domain.MemberPart; | ||
import shook.shook.member_part.domain.repository.MemberPartRepository; | ||
import shook.shook.song.domain.Song; | ||
import shook.shook.song.domain.repository.SongRepository; | ||
import shook.shook.song.exception.SongException.SongNotExistException; | ||
|
||
@RequiredArgsConstructor | ||
@Transactional(readOnly = true) | ||
@Service | ||
public class MemberPartService { | ||
|
||
private final SongRepository songRepository; | ||
private final MemberRepository memberRepository; | ||
private final MemberPartRepository memberPartRepository; | ||
|
||
@Transactional | ||
public void register(final Long songId, final Long memberId, final MemberPartRegisterRequest request) { | ||
final Song song = getSong(songId); | ||
final Member member = getMember(memberId); | ||
validateAlreadyExistMemberPart(song, member); | ||
|
||
final MemberPart memberPart = MemberPart.forSave(request.getStartSecond(), request.getLength(), song, member); | ||
memberPartRepository.save(memberPart); | ||
} | ||
|
||
private void validateAlreadyExistMemberPart(final Song song, final Member member) { | ||
final boolean existsMemberPart = memberPartRepository.existsByMemberAndSong(member, song); | ||
|
||
if (existsMemberPart) { | ||
throw new MemberException.MemberPartAlreadyExistException( | ||
Map.of("songId", String.valueOf(song.getId()), | ||
"memberId", String.valueOf(member.getId())) | ||
); | ||
} | ||
} | ||
|
||
private Member getMember(final Long memberId) { | ||
return memberRepository.findById(memberId) | ||
.orElseThrow(() -> new MemberException.MemberNotExistException( | ||
Map.of("memberId", String.valueOf(memberId)) | ||
)); | ||
} | ||
|
||
private Song getSong(final Long songId) { | ||
return songRepository.findById(songId) | ||
.orElseThrow(() -> new SongNotExistException( | ||
Map.of("songId", String.valueOf(songId)) | ||
)); | ||
} | ||
|
||
@Transactional | ||
public void delete(final Long memberId, final Long memberPartId) { | ||
final MemberPart memberPart = memberPartRepository.findByMemberIdAndId(memberId, memberPartId) | ||
.orElseThrow(() -> new AuthorizationException.UnauthenticatedException( | ||
Map.of("memberId", String.valueOf(memberId), "memberPartId", String.valueOf(memberPartId)) | ||
)); | ||
|
||
memberPartRepository.delete(memberPart); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
backend/src/main/java/shook/shook/member_part/application/dto/MemberPartRegisterRequest.java
This file contains 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,27 @@ | ||
package shook.shook.member_part.application.dto; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Positive; | ||
import jakarta.validation.constraints.PositiveOrZero; | ||
import lombok.AccessLevel; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Schema(description = "멤버 파트 등록 요청") | ||
@NoArgsConstructor(access = AccessLevel.PRIVATE) | ||
@AllArgsConstructor | ||
@Getter | ||
public class MemberPartRegisterRequest { | ||
|
||
@Schema(description = "멤버 파트 시작 초", example = "23") | ||
@NotNull | ||
@PositiveOrZero | ||
private Integer startSecond; | ||
|
||
@Schema(description = "멤버 파트 길이", example = "10") | ||
@NotNull | ||
@Positive | ||
private Integer length; | ||
} |
Oops, something went wrong.