package com.framework.mvvm.model.db.dao

import androidx.room.*
import com.framework.mvvm.model.db.entity.SpaceEntity

/**
 * 表 space Dao
 */
@Dao
interface SpaceDao {
    @Query("select * from space")
    suspend fun getSpaces(): List<SpaceEntity>

    @Query("select * from space where id = :id")
    suspend fun getSpaceById(id: String): SpaceEntity

    @Query("select * from space where space_id = :id")
    suspend fun getSpaceBySpaceId(id: String): SpaceEntity

    @Query("select * from space where floor_id = :id and arch_state =:archState")
    suspend fun getSpaceByArchStateFloorId(id: String, archState: String): List<SpaceEntity>

    @Query("select * from space where floor_id = :id and equip_state =:equipState")
    suspend fun getSpaceByEquipStateFloorId(id: String, equipState: String): List<SpaceEntity>

    @Query("select * from space where building_id = :id")
    suspend fun getSpaceByBuildingId(id: String): List<SpaceEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insSpace(vararg space: SpaceEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insSpaces(spaces: List<SpaceEntity>)

    @Update
    suspend fun updateSpaces(spaces: List<SpaceEntity>)

    @Delete
    suspend fun delSpace(space: SpaceEntity)
}