Code refactor
This commit is contained in:
parent
543893adba
commit
cee4565c34
35 changed files with 107 additions and 43 deletions
|
@ -0,0 +1,10 @@
|
|||
package code.name.monkey.retromusic.db
|
||||
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
|
||||
@Entity
|
||||
class BlackListStoreEntity(
|
||||
@PrimaryKey
|
||||
val path: String
|
||||
)
|
|
@ -9,10 +9,10 @@ interface PlaylistDao {
|
|||
suspend fun createPlaylist(playlistEntity: PlaylistEntity): Long
|
||||
|
||||
@Query("UPDATE PlaylistEntity SET playlist_name = :name WHERE playlist_id = :playlistId")
|
||||
suspend fun renamePlaylistEntity(playlistId: Int, name: String)
|
||||
suspend fun renamePlaylist(playlistId: Int, name: String)
|
||||
|
||||
@Query("SELECT * FROM PlaylistEntity WHERE playlist_name = :name")
|
||||
fun checkPlaylistExists(name: String): List<PlaylistEntity>
|
||||
fun isPlaylistExists(name: String): List<PlaylistEntity>
|
||||
|
||||
@Query("SELECT * FROM PlaylistEntity")
|
||||
suspend fun playlists(): List<PlaylistEntity>
|
||||
|
@ -20,27 +20,27 @@ interface PlaylistDao {
|
|||
@Query("DELETE FROM SongEntity WHERE playlist_creator_id = :playlistId")
|
||||
suspend fun deleteSongsInPlaylist(playlistId: Int)
|
||||
|
||||
@Query("DELETE FROM SongEntity WHERE playlist_creator_id = :playlistId AND id = :songId")
|
||||
suspend fun removeSongFromPlaylist(playlistId: Int, songId: Int)
|
||||
|
||||
@Transaction
|
||||
@Query("SELECT * FROM PlaylistEntity")
|
||||
suspend fun playlistsWithSong(): List<PlaylistWithSongs>
|
||||
suspend fun playlistsWithSongs(): List<PlaylistWithSongs>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertSongs(songEntities: List<SongEntity>)
|
||||
suspend fun insertSongsToPlaylist(songEntities: List<SongEntity>)
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistId AND id = :songId")
|
||||
suspend fun checkSongExistsWithPlaylistId(playlistId: Int, songId: Int): List<SongEntity>
|
||||
suspend fun isSongExistsInPlaylist(playlistId: Int, songId: Int): List<SongEntity>
|
||||
|
||||
@Query("SELECT * FROM SongEntity WHERE playlist_creator_id = :playlistId")
|
||||
suspend fun getSongs(playlistId: Int): List<SongEntity>
|
||||
|
||||
@Query("DELETE FROM SongEntity WHERE playlist_creator_id = :playlistId AND id = :songId")
|
||||
fun removeSong(playlistId: Int, songId: Int)
|
||||
suspend fun songsFromPlaylist(playlistId: Int): List<SongEntity>
|
||||
|
||||
@Delete
|
||||
suspend fun deletePlaylistEntity(playlistEntity: PlaylistEntity)
|
||||
suspend fun deletePlaylist(playlistEntity: PlaylistEntity)
|
||||
|
||||
@Delete
|
||||
suspend fun deletePlaylistEntities(playlistEntities: List<PlaylistEntity>)
|
||||
suspend fun deletePlaylists(playlistEntities: List<PlaylistEntity>)
|
||||
|
||||
@Delete
|
||||
suspend fun deleteSongsInPlaylist(songs: List<SongEntity>)
|
||||
|
@ -77,4 +77,16 @@ interface PlaylistDao {
|
|||
|
||||
@Query("SELECT * FROM PlayCountEntity ORDER BY play_count DESC")
|
||||
fun playCountSongs(): List<PlayCountEntity>
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insertBlacklistPath(blackListStoreEntity: BlackListStoreEntity)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertBlacklistPath(blackListStoreEntities: List<BlackListStoreEntity>)
|
||||
|
||||
@Delete
|
||||
suspend fun deleteBlacklistPath(blackListStoreEntity: BlackListStoreEntity)
|
||||
|
||||
@Query("DELETE FROM BlackListStoreEntity")
|
||||
suspend fun clearBlacklist()
|
||||
}
|
|
@ -4,8 +4,8 @@ import androidx.room.Database
|
|||
import androidx.room.RoomDatabase
|
||||
|
||||
@Database(
|
||||
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class],
|
||||
version = 17,
|
||||
entities = [PlaylistEntity::class, SongEntity::class, HistoryEntity::class, PlayCountEntity::class, BlackListStoreEntity::class],
|
||||
version = 18,
|
||||
exportSchema = false
|
||||
)
|
||||
abstract class RetroDatabase : RoomDatabase() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue