Newer
Older
bremer / src / main / kotlin / entity / Entity.kt
/*
 * Copyright (c) 2023. yo-saito. All Rights Reserved.
 */

package net.piedpiper.bremer.entity

import net.piedpiper.bremer.utils.sql.Column
import net.piedpiper.bremer.utils.sql.Table
import java.time.LocalDateTime

@Table("audio")
data class AudioEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("slug")
    var slug: String = "",
    @property:Column("name")
    var name: String = "",
    @property:Column("album_id")
    var albumId: Long = 0L,
    @property:Column("sequence")
    var sequence: Int = 0,
    @property:Column("path")
    var path: String = "",
    // join
    var album: AlbumEntity? = null,
    var aliasNames: List<AudioNameEntity>? = null
)

@Table("audio_name")
data class AudioNameEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("audio_id")
    var audioId: Long = 0L,
    @property:Column("name")
    var name: String = ""
)

@Table("album")
data class AlbumEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("artist_id")
    var artistId: Long = 0L,
    @property:Column("name")
    var name: String = "",
    // join
    var artist: ArtistEntity? = null
)

@Table("artist")
data class ArtistEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("name")
    var name: String = "",
)

@Table("audio_tag")
data class AudioTagEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("audio_id")
    var audioId: Long = 0L,
    @property:Column("tag_id")
    var tagId: Long = 0L
)

@Table("user")
data class UserEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("account_id")
    var accountId: String = "",
    @property:Column("secret")
    var secret: String = "",
)

@Table("audio_play_history")
data class AudioPlayHistoryEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("audio_id")
    var audioId: Long = 0L,
    @property:Column("last_played_at")
    var lastPlayedAt: LocalDateTime = LocalDateTime.MIN
)

@Table("playlist")
data class PlaylistEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("slug")
    var slug: String = "",
    @property:Column("name")
    var name: String = "",
    @property:Column("sequence")
    var sequence: Int = 0,
    // join
    var playlistAudio: List<PlaylistAudioEntity> = mutableListOf()
)

@Table("playlist_audio")
data class PlaylistAudioEntity(
    @property:Column("id", updatable = false)
    var id: Long = 0L,
    @property:Column("playlist_id")
    var playlistId: Long = 0L,
    @property:Column("sequence")
    var sequence: Int = 0,
    @property:Column("audio_id")
    var audioId: Long = 0L
)

@Table("tag")
data class TagEntity(
    @property:Column("id", insertable = false, updatable = false)
    var id: Long = 0L,
    @property:Column("slug")
    var slug: String = "",
    @property:Column("name")
    var name: String = "",
)