package com.apps.pixwall.data

import androidx.lifecycle.LiveData

class PaperRepository(private val paperDao: PaperDao) {
    suspend fun allPaper():List<Paper>{
        return paperDao.getAllPapers()
    }
//    suspend fun insertPaper(paper: Paper){
//        paperDao.insert(paper)
//    }
    suspend fun updatePaper(paper: Paper){
        paperDao.update(paper)
    }
    suspend fun getPaperById(id:String):Paper?{
        return paperDao.getById(id)
    }
    suspend fun getCategoryCover(name:String):List<Paper>{
        return paperDao.queryCover(name)
    }
    suspend fun getPaperByCategory(name: String):List<Paper>{
        return paperDao.queryEachGenera(name)
    }
    fun getLikes():LiveData<List<Paper>>{
        return paperDao.queryLikePaper()
    }
    suspend fun searchByKey(key:String):List<Paper>{
        return paperDao.search(key)
    }
    suspend fun isLike(id: String): Boolean = paperDao.queryIsLike(id) != null
}