package com.ys.bdtp.adm.mvvm.model.db.dao

import androidx.room.*
import com.ys.bdtp.adm.mvvm.model.db.entity.dict.EquipmentEntity

/**
 * 表 equipment Dao
 */
@Dao
interface EquipmentDao {
    @Query("select * from equipment")
    suspend fun getEquipments(): List<EquipmentEntity>

    @Query("select * from equipment where id = :id and valid = 1")
    suspend fun getEquipmentById(id: String): EquipmentEntity

    @Query("select * from equipment where code = :code and valid = 1")
    suspend fun getEquipmentByCode(code: String): EquipmentEntity?

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insEquipment(vararg equipment: EquipmentEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insEquipments(equipments: List<EquipmentEntity>)

    @Delete
    suspend fun delEquipment(equipment: EquipmentEntity)
}