package in.techware.carrefour.dbUtils.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import java.util.List;

import in.techware.carrefour.dbUtils.entity.PrintLabelEntity;


/**
 * Created by Jemsheer K D on 25 July, 2018.
 * Package in.techware.carrefour.dbUtils.dao
 * Project Carrefour
 */

@Dao
public interface PrintLabelDao {

    @Query("SELECT * FROM printLabel")
    List<PrintLabelEntity> loadAllPrintLabels();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<PrintLabelEntity> printLabelEntityList);


    @Query("select * from printLabel where id = :id ORDER BY id DESC LIMIT 1")
    List<PrintLabelEntity> getPrintLabel(String id);

    @Query("select * from printLabel where sendStatus = 0 ORDER BY id")
    List<PrintLabelEntity> getAllUnsentPrintLabel();

    @Query("select * from printLabel where sendStatus = 0 AND labelType = :labelType ORDER BY id")
    List<PrintLabelEntity> getAllUnsentPrintLabel(int labelType);

    @Query("select * from printLabel where sendStatus = 1 ORDER BY id")
    List<PrintLabelEntity> getAllSentPrintLabel();

    @Query("select * from printLabel where sendStatus = 1 AND labelType = :labelType ORDER BY id")
    List<PrintLabelEntity> getAllSentPrintLabel(int labelType);

    @Query("DELETE from printLabel where sendStatus = 0")
    void deleteAllUnsentPrintLabel();

    @Query("DELETE from printLabel where sendStatus = 0 AND labelType = :labelType")
    void deleteAllUnsentPrintLabel(int labelType);

    @Query("DELETE from printLabel where sendStatus = 1")
    void deleteAllSentPrintLabel();

    @Query("DELETE from printLabel where sendStatus = 1 AND labelType = :labelType AND printerLabel= :key")
    void deleteAllSentPrintLabel(String key, int labelType);

    @Query("DELETE FROM printLabel where labelType = :labelType")
    void deleteAll(int labelType);

    @Query("DELETE FROM printLabel")
    void deleteAll();

    @Insert
    long insert(PrintLabelEntity printLabelEntity);

    @Update
    void update(PrintLabelEntity printLabelEntity);

    @Delete
    void delete(PrintLabelEntity printLabelEntity);
}
