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

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Transaction
import com.ys.bdtp.adm.mvvm.model.db.entity.task.BuildingEntity
import com.ys.bdtp.adm.mvvm.model.db.relation.BuildingWithFloors
import kotlinx.coroutines.flow.Flow

/**
 * building 表访问接口
 */
@Dao
interface BuildingDao {
    @Query("select * from building")
    suspend fun getBuildings(): List<BuildingEntity>

    @Query("select * from building where id = :id")
    suspend fun getBuildingById(id: String): BuildingEntity?

    @Insert
    suspend fun insBuilding(vararg floor: BuildingEntity)

    @Insert
    suspend fun insBuildings(floors: List<BuildingEntity>)

    @Transaction
    @Query("select * from building")
    fun getBuildingWithFloors(): Flow<BuildingWithFloors>
}