package com.navinfo.outdoor.room;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * 访问数据库操作的接口
 */
@Dao
public interface ChargingPileDao {
    /**
     * 查询
     * @return
     */
    @Query("SELECT * FROM pile")
    List<ChargingPileEntity> getChargingPile();
    /**
     * 查询
     * @return
     */
    @Query("SELECT * FROM pile where fid = :fid")
    List<ChargingPileEntity> getChargingPileByStationId(String fid);

    /**
     * 添加
     * @param chargingPileEntities
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[] insertChargingPileEntity(ChargingPileEntity... chargingPileEntities);

    /**
     * 更新
     * @param chargingPileEntities
     */
    @Update
    void updateChargingPileEntity(ChargingPileEntity... chargingPileEntities);

    /**
     * 删除
     * @param chargingPileEntities
     */
    @Delete
    void deleteChargingPileEntity(ChargingPileEntity... chargingPileEntities);
    /**
     * 删除
     */
    @Query("DELETE  FROM pile where fid=:fid")
    void deleteChargingFidPileEntity(String fid);
    /**
     *删除
     * @param chargingPileEntities
     */
    @Delete
    void deleteAll(List<ChargingPileEntity> chargingPileEntities);

    /**
     * 全部删除
     */
    @Query("DELETE FROM pile")
    void deleteAllChargingPileEntity();

    /**
     * 降序排列
     * @return
     */
    @Query("SELECT * FROM pile ORDER BY pileId DESC")
    List<ChargingPileEntity> getAllChargingPileEntity();


}
