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

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

/**
 * 表 file Dao
 */
@Dao
interface FileDao {
    @Query("select * from file")
    suspend fun getFiles(): List<FileEntity>

    @Query("select * from file where id = :id")
    suspend fun getFileById(id: String): FileEntity

    @Query("select * from file where ref_obj_id = :id")
    suspend fun getFileByRefId(id: String): List<FileEntity>

    @Query("select * from file where building_id = :id")
    suspend fun getFileByBuildingId(id: String): List<FileEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insFile(vararg file: FileEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insFiles(files: List<FileEntity>)

    @Update
    suspend fun updateFiles(files: List<FileEntity>)

    @Delete
    suspend fun delFile(file: FileEntity)
}