package com.za.room.db.order

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import androidx.room.Update
import com.za.bean.db.order.OrderInfo

@Dao
interface OrderDao {
    //更换电瓶照片
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertOrder(orderInfo: OrderInfo)

    @Query("select * from order_info where taskId =:taskId")
    fun getOrderInfoFromTaskId(taskId: Int): OrderInfo?

    //获取当前正在执行的订单
    @Query("select * from order_info where isCurrent ==1")
    fun getCurrentOrder(): OrderInfo?

    //获取不是当前正在执行的订单
    @Query("select * from order_info where isCurrent !=1")
    fun getAllNotCurrentOrder(): List<OrderInfo>?

    //获取所有的订单
    @Query("select * from order_info")
    fun getAllOrder(): List<OrderInfo>?

    @Query("delete from order_info")
    fun deleteAllOrder()

    @Query("delete from order_info where taskId =:taskId")
    fun deleteOrderFromTaskId(taskId: Int)

    @Update(onConflict = OnConflictStrategy.REPLACE)
    fun update(orderInfo: OrderInfo)
}