package com.wall.photography.wallpaper.room

import androidx.lifecycle.LiveData
import androidx.paging.PagingSource
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.wall.photography.wallpaper.data.Bean


@Dao
interface BeanDao {

    @Insert(onConflict = OnConflictStrategy.IGNORE)
    fun insertBean(bean: Bean)

    @Update
    fun updateBean(bean: Bean)

    @Query("delete from wall_paper")
    fun deleteTBData()


    @Query("select * from wall_paper order by id desc")
    fun getAllWallpaper(): List<Bean>

    @Query("select * from wall_paper where id==:myId")
    fun getCurWallpaper(myId: Int): Bean

    @Query("select * from wall_paper where love==:isLove order by id desc ")
     fun getLoveWallpaper(isLove:Boolean = true): LiveData<List<Bean>>

    @Query("select * from wall_paper where love==:isLove order by id desc LIMIT :pageSize OFFSET :pageNUmber")
    suspend fun getPagingLoveWallpaper(isLove:Boolean = true,pageSize: Int, pageNUmber: Int): List<Bean>


    @Query("select * from wall_paper where cateName==:cateName order by id desc LIMIT 1 OFFSET 2")
    suspend fun getCategoryCovert(cateName: String): Bean?


    @Query("select * from wall_paper where cateName==:cateName order by id desc LIMIT :pageSize OFFSET :pageNUmber")
    suspend fun getNextWallpaper(cateName: String, pageSize: Int, pageNUmber: Int): List<Bean>
}