/* * Copyright (c) 2023. yo-saito. All Rights Reserved. */ package net.piedpiper.bremer.model.api import com.fasterxml.jackson.annotation.JsonProperty import net.piedpiper.bremer.entity.AudioEntity import net.piedpiper.bremer.entity.PlaylistEntity import net.piedpiper.bremer.entity.TagEntity data class Audio( private val audioEntity: AudioEntity ) { val name: String = audioEntity.name val slug: String = audioEntity.slug val artist: String? = audioEntity?.album?.artist?.name val album: String? = audioEntity?.album?.name var sequence: Int? = if (audioEntity?.sequence == 0) { audioEntity?.sequence } else { null } var aliasNames: List<String>? = audioEntity?.aliasNames?.map { it.name } } data class Tag( private val tagEntity: TagEntity ) { val slug: String = tagEntity.slug val name: String = tagEntity.name } data class AllPlaylistResponse( private val entities: List<PlaylistEntity> ) { val playlist: List<Playlist> = entities.map { Playlist(it.name, it.sequence, it.slug) } data class Playlist( val name: String, var sequence: Int, val slug: String ) } data class AudioListResponse( private val entities: List<AudioEntity> = emptyList() ) { @field:JsonProperty("audio_list") val audioList: List<Audio> = entities.map { Audio(it) } } data class PlaylistAudioResponse( private val playlistEntity: PlaylistEntity, private val audioEntityList: List<AudioEntity>? = null ) { val name: String = playlistEntity.name val slug: String = playlistEntity.slug @field:JsonProperty("audio_list") val audioList: List<Audio>? = audioEntityList?.map { Audio(it) } ?: null } data class TagAudioResponse( private val tagEntity: TagEntity, private val audioEntityList: List<AudioEntity> ) { val name: String = tagEntity.name val slug: String = tagEntity.slug @field:JsonProperty("audio_list") val audioList: List<Audio> = audioEntityList.map { Audio(it) } } data class AllTagsResponse( private val tagEntities: List<TagEntity> ) { val tags: List<Tag> = tagEntities.map { Tag(it) } }