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

import androidx.room.*
import com.framework.mvvm.model.db.entity.task.ProblemArchEntity

/**
 * 表 problem_arch Dao
 */
@Dao
interface ProblemArchDao {
    @Query("select * from problem_arch")
    suspend fun getProblems(): List<ProblemArchEntity>

    @Query("select * from problem_arch where id = :id")
    suspend fun getProblemById(id: String): ProblemArchEntity

    @Query("select * from problem_arch where floor_id = :floorId")
    suspend fun getProblemByFloor(floorId: String): List<ProblemArchEntity>

    @Query("select * from problem_arch where floor_id = :floorId and valid = 1 and problem_state = 1")
    suspend fun getProblemByAvalible(floorId: String): List<ProblemArchEntity>

    @Query("select * from problem_arch where building_id = :id")
    suspend fun getProblemByBuildingId(id: String): List<ProblemArchEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insProblem(problem: ProblemArchEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insProblems(problems: List<ProblemArchEntity>)

    @Update
    suspend fun updateProblems(problems: List<ProblemArchEntity>)

    @Delete
    suspend fun delProblem(problem: ProblemArchEntity)

}