package com.wallpaper.wallpaperbox.data.dao;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import com.wallpaper.wallpaperbox.data.entity.WallpaperEntity;

import java.util.List;

@Dao
public interface WallpaperEntityDao {
    @Insert
    void insertAll(List<WallpaperEntity> wallpaperEntities);

    @Update
    void update(WallpaperEntity wallpaperEntity);

    @Query("SELECT * FROM WallpaperEntity WHERE isLike = 1 ")
    LiveData<List<WallpaperEntity>> getLike();

    @Query("SELECT * FROM WallpaperEntity WHERE id IN (SELECT MIN(id) FROM WallpaperEntity GROUP BY name)")
    LiveData<List<WallpaperEntity>> getFirstWallpaper();

    @Query("SELECT * FROM WallpaperEntity WHERE name = :name")
    LiveData<List<WallpaperEntity>> getCategoryByName(String name);

    @Query("SELECT isLike FROM WallpaperEntity WHERE source = :source AND name = :name")
    LiveData<Boolean> getWallpaperLike(String source, String name);
}
