test #243
@@ -55,4 +55,14 @@ class AudioContentPlaylistController(private val service: AudioContentPlaylistSe
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        ApiResponse.ok(service.getPlaylists(member))
 | 
					        ApiResponse.ok(service.getPlaylists(member))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @GetMapping("/{id}")
 | 
				
			||||||
 | 
					    fun getPlaylistDetail(
 | 
				
			||||||
 | 
					        @PathVariable id: Long,
 | 
				
			||||||
 | 
					        @AuthenticationPrincipal(expression = "#this == 'anonymousUser' ? null : member") member: Member?
 | 
				
			||||||
 | 
					    ) = run {
 | 
				
			||||||
 | 
					        if (member == null) throw SodaException("로그인 정보를 확인해주세요.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ApiResponse.ok(service.getPlaylistDetail(playlistId = id, member = member))
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,8 @@ import kr.co.vividnext.sodalive.live.roulette.RedisIdGenerator
 | 
				
			|||||||
import kr.co.vividnext.sodalive.member.Member
 | 
					import kr.co.vividnext.sodalive.member.Member
 | 
				
			||||||
import org.springframework.data.repository.findByIdOrNull
 | 
					import org.springframework.data.repository.findByIdOrNull
 | 
				
			||||||
import org.springframework.stereotype.Service
 | 
					import org.springframework.stereotype.Service
 | 
				
			||||||
 | 
					import java.time.ZoneId
 | 
				
			||||||
 | 
					import java.time.format.DateTimeFormatter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Service
 | 
					@Service
 | 
				
			||||||
class AudioContentPlaylistService(
 | 
					class AudioContentPlaylistService(
 | 
				
			||||||
@@ -113,6 +115,33 @@ class AudioContentPlaylistService(
 | 
				
			|||||||
        redisRepository.delete(playlist)
 | 
					        redisRepository.delete(playlist)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    fun getPlaylistDetail(playlistId: Long, member: Member): GetPlaylistDetailResponse {
 | 
				
			||||||
 | 
					        val playlist = redisRepository.findByIdOrNull(id = playlistId)
 | 
				
			||||||
 | 
					            ?: throw SodaException("잘못된 요청입니다.")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (playlist.memberId != member.id) {
 | 
				
			||||||
 | 
					            throw SodaException("잘못된 요청입니다.")
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        val dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd")
 | 
				
			||||||
 | 
					        val createdDate = playlist.createdAt
 | 
				
			||||||
 | 
					            .atZone(ZoneId.of("UTC"))
 | 
				
			||||||
 | 
					            .withZoneSameInstant(ZoneId.of("Asia/Seoul"))
 | 
				
			||||||
 | 
					            .format(dateTimeFormatter)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        val contentList = audioContentRepository.fetchContentForPlaylist(contentIdList = playlist.contentIdList)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return GetPlaylistDetailResponse(
 | 
				
			||||||
 | 
					            playlistId = playlist.id,
 | 
				
			||||||
 | 
					            title = playlist.title,
 | 
				
			||||||
 | 
					            desc = playlist.desc ?: "",
 | 
				
			||||||
 | 
					            createdDate = createdDate,
 | 
				
			||||||
 | 
					            contentCount = contentList.size,
 | 
				
			||||||
 | 
					            playlistCoverImageList = contentList.take(4).map { it.coverUrl },
 | 
				
			||||||
 | 
					            contentList = contentList
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    companion object {
 | 
					    companion object {
 | 
				
			||||||
        const val SEQUENCE_NAME = "AudioContentPlaylist:sequence"
 | 
					        const val SEQUENCE_NAME = "AudioContentPlaylist:sequence"
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					package kr.co.vividnext.sodalive.content.playlist
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					data class GetPlaylistDetailResponse(
 | 
				
			||||||
 | 
					    val playlistId: Long,
 | 
				
			||||||
 | 
					    val title: String,
 | 
				
			||||||
 | 
					    val desc: String,
 | 
				
			||||||
 | 
					    val createdDate: String,
 | 
				
			||||||
 | 
					    val contentCount: Int,
 | 
				
			||||||
 | 
					    val playlistCoverImageList: List<String>,
 | 
				
			||||||
 | 
					    val contentList: List<AudioContentPlaylistContent>
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
		Reference in New Issue
	
	Block a user