package com.ys.bdtp.adm.mvvm.vm.cad

import com.ys.bdtp.adm.mvvm.model.Data
import com.ys.bdtp.adm.mvvm.model.db.AdmDatabase
import com.ys.bdtp.adm.mvvm.model.db.relation.FloorWithCads
import com.ys.bdtp.adm.mvvm.model.db.relation.BuildingWithFloors
import com.ys.bdtp.adm.mvvm.model.db.relation.ProjectWithBuildingAndFloors
import com.ys.bdtp.adm.mvvm.model.nt.Api
import com.ys.bdtp.adm.mvvm.model.toStateFlow
import kotlinx.coroutines.flow.Flow


class CadRepository(private val api: Api, private val db: AdmDatabase) {



    /**
     * 获取项目以及项目下的建筑和楼层
     */
    fun getProjectWithBuildingAndFloors(id: String): Flow<Data<ProjectWithBuildingAndFloors>> {
        return db.projectDao().getProjectWithBuildingAndFloorsById(id).toStateFlow()
    }

    fun getFloorWithCads(id: String): Flow<Data<FloorWithCads>> {
        return db.floorDao().getFloorWithCadsById(id).toStateFlow()
    }

}
