/* * Copyright (c) 2023. yo-saito. All Rights Reserved. */ package net.piedpiper.bremer.model import com.fasterxml.jackson.annotation.JsonInclude import com.fasterxml.jackson.annotation.JsonProperty import jakarta.validation.constraints.NotBlank import jakarta.validation.constraints.NotEmpty import net.piedpiper.bremer.entity.AudioEntity import net.piedpiper.bremer.entity.PlaylistEntity data class PlaylistListResponse( private val entities: List<PlaylistEntity> ) { val playlist: List<Playlist> = entities.map { Playlist(it.name, it.slug) } data class Playlist( val name: String, val slug: String ) } data class PlaylistRequest( @field:NotBlank val name: String = "", @field:NotEmpty @field:JsonProperty("audio_slugs") val audioSlugs: List<String> = mutableListOf() ) class PlaylistAudioResponse( private val playlistEntity: PlaylistEntity, private val audioEntityList: List<AudioEntity> ) { val name: String = playlistEntity.name val slug: String = playlistEntity.slug @field:JsonProperty("audio_list") val audioList: List<Audio> = audioEntityList.map { Audio(it) } @JsonInclude(JsonInclude.Include.NON_NULL) class Audio(private val entity: AudioEntity) { val name: String = entity.name val slug: String = entity.slug val artist: String? = entity.album?.artist?.name val album: String? = entity.album?.name } }