플레이 리스트 생성 API
- 기존: 플레이 리스트에 콘텐츠 ID만 저장됨 - 변경: 콘텐츠 ID와 정렬순서도 같이 저장됨
This commit is contained in:
parent
7f4de67d67
commit
22c5c5be25
|
@ -15,7 +15,7 @@ data class AudioContentPlaylist(
|
|||
val memberId: Long,
|
||||
var title: String,
|
||||
var desc: String? = null,
|
||||
var contentIdList: MutableList<Long> = mutableListOf(),
|
||||
var contentIdAndOrderList: MutableList<PlaylistContentIdAndOrder> = mutableListOf(),
|
||||
|
||||
// ISO 8601 형식의 String
|
||||
private val _createdAt: String = LocalDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME)
|
||||
|
|
|
@ -16,7 +16,7 @@ class AudioContentPlaylistService(
|
|||
private val redisRepository: AudioContentPlaylistRedisRepository
|
||||
) {
|
||||
fun createPlaylist(request: CreatePlaylistRequest, member: Member) {
|
||||
if (request.contentIdList.size >= 30) {
|
||||
if (request.contentIdAndOrderList.size >= 30) {
|
||||
throw SodaException("플레이 리스트에는 최대 30개의 콘텐츠를 저장할 수 있습니다.")
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class AudioContentPlaylistService(
|
|||
|
||||
// 콘텐츠 유효성 검사 (소장으로 구매한 콘텐츠 인가?)
|
||||
checkOrderedContent(
|
||||
contentIdList = request.contentIdList,
|
||||
contentIdList = request.contentIdAndOrderList.map { it.contentId },
|
||||
memberId = member.id!!
|
||||
)
|
||||
|
||||
|
@ -37,7 +37,7 @@ class AudioContentPlaylistService(
|
|||
title = request.title,
|
||||
desc = request.desc
|
||||
)
|
||||
playlist.contentIdList.addAll(request.contentIdList)
|
||||
playlist.contentIdAndOrderList.addAll(request.contentIdAndOrderList)
|
||||
|
||||
redisRepository.save(playlist)
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ class AudioContentPlaylistService(
|
|||
return GetPlaylistsResponse(
|
||||
totalCount = playlists.size,
|
||||
items = playlists.map {
|
||||
val contentCount = it.contentIdList.size
|
||||
val contentCount = it.contentIdAndOrderList.size
|
||||
val coverImageUrl = if (contentCount > 0) {
|
||||
audioContentRepository.getCoverImageById(id = it.contentIdList[0])
|
||||
audioContentRepository.getCoverImageById(id = it.contentIdAndOrderList[0].contentId)
|
||||
?: ""
|
||||
} else {
|
||||
""
|
||||
|
|
|
@ -3,5 +3,5 @@ package kr.co.vividnext.sodalive.content.playlist
|
|||
data class CreatePlaylistRequest(
|
||||
val title: String,
|
||||
val desc: String? = null,
|
||||
val contentIdList: List<Long> = emptyList()
|
||||
val contentIdAndOrderList: List<PlaylistContentIdAndOrder> = emptyList()
|
||||
)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package kr.co.vividnext.sodalive.content.playlist
|
||||
|
||||
data class PlaylistContentIdAndOrder(
|
||||
val contentId: Long,
|
||||
val order: Int
|
||||
)
|
Loading…
Reference in New Issue