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.FloorEntity
import com.ys.bdtp.adm.mvvm.model.db.relation.FloorWithCads
import kotlinx.coroutines.flow.Flow

/**
 * floor 表访问接口
 */
@Dao
interface FloorDao {

    @Query("select * from floor")
    suspend fun getFloors(): List<FloorEntity>

    @Query("select * from floor where id = :id")
    suspend fun getFloorById(id: String): FloorEntity?

    @Insert
    suspend fun insFloor(vararg floor: FloorEntity)

    @Insert
    suspend fun insFloors(floors: List<FloorEntity>)

    /**
     *
     */
    @Transaction
    @Query("select * from floor where id = :id")
    fun getFloorWithCadsById(id: String): Flow<FloorWithCads>
}