package com.offline.music.task.player.db.bean

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update

@Dao
interface LocalAudioDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAudioFile(barcode: Audio)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertAudioFiles(audios: List<Audio>)

    @Query("SELECT * FROM Audio")
    suspend fun getAllAudioFile(): List<Audio>

    @Delete
    suspend fun deleteAudioFile(barcode: Audio)

    @Query("DELETE FROM Audio")
    suspend fun deleteAllAudioFile()

    @Update
    suspend fun updateAudioFile(audioFile: Audio)

    @Query("SELECT * FROM Audio WHERE name = :path LIMIT 1")
    suspend fun getAudioFileByPath(path: String): Audio?

    @Query("SELECT * FROM Audio WHERE selected = 1")
    suspend fun getAudioBySelected(): List<Audio>

    @Query("update Audio set collect = 0")
    suspend fun deleteAllCollect()

    @Query("select * from Audio where collect = :collect ")
    suspend fun getCollectData(collect: Boolean = true): List<Audio>
}
