플레이 리스트 생성 API - 유효성 검사
- 콘텐츠가 1개 이상 등록되어 있어야 한다.
This commit is contained in:
@@ -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 }
|
||||
|
Reference in New Issue
Block a user