플레이 리스트 생성 API - 유효성 검사

- 콘텐츠가 1개 이상 등록되어 있어야 한다.
This commit is contained in:
Klaus 2024-12-04 10:59:43 +09:00
parent 72563e9bfa
commit 72cb90357e
1 changed files with 12 additions and 1 deletions

View File

@ -28,7 +28,7 @@ class AudioContentPlaylistService(
}
// 콘텐츠 유효성 검사 (소장으로 구매한 콘텐츠 인가?)
checkOrderedContent(
validateContent(
contentIdList = request.contentIdAndOrderList.map { it.contentId },
memberId = member.id!!
)
@ -44,6 +44,17 @@ class AudioContentPlaylistService(
redisRepository.save(playlist)
}
private fun validateContent(contentIdList: List<Long>, memberId: Long) {
if (contentIdList.isEmpty()) {
throw SodaException("콘텐츠를 1개 이상 추가하세요")
}
checkOrderedContent(
contentIdList = contentIdList,
memberId = memberId
)
}
private fun checkOrderedContent(contentIdList: List<Long>, memberId: Long) {
val orderedContentIdList = orderRepository.findOrderedContent(contentIdList, memberId).toSet()
val orderedContentMap = contentIdList.associateWith { it in orderedContentIdList }