package it.integry.integrywmsnative.core.data_store.db.dao;

import androidx.room.Dao;
import androidx.room.Query;

import java.util.List;

import io.reactivex.rxjava3.core.Flowable;
import it.integry.integrywmsnative.core.data_store.db.entity.BaseSyncDTO;
import it.integry.integrywmsnative.core.data_store.db.entity.InventarioRoomDTO;
import it.integry.integrywmsnative.core.data_store.db.interfaces.EntityDaoInterface;

@Dao
public interface InventarioDao extends EntityDaoInterface<InventarioRoomDTO> {


    @Query("SELECT * FROM " + InventarioRoomDTO.TABLE_NAME +
            " WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))")
    List<InventarioRoomDTO> selectAll(boolean toBeSync);


    @Query("SELECT * FROM " + InventarioRoomDTO.TABLE_NAME +
            " WHERE ((:toBeSync = 1 AND " + BaseSyncDTO.Columns.COLUMN_REMOTE_SYNC_DATE + " IS NULL) OR (:toBeSync = 0))" +
            " ORDER BY " + InventarioRoomDTO.Columns.DATA_INVENTARIO + " DESC")
    Flowable<List<InventarioRoomDTO>> selectAllFlowable(boolean toBeSync);

}
