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

import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.ys.bdtp.adm.mvvm.model.db.entity.dict.RelConfigEntity

/**
 * 表 rel_config Dao
 */
@Dao
interface RelConfigDao {
    @Query("select * from rel_config")
    suspend fun getConfigs(): List<RelConfigEntity>

    @Query("select * from rel_config where id = :id")
    suspend fun getConfigById(id: String): RelConfigEntity

    @Query("select * from rel_config where class_code_from = :code")
    suspend fun getConfigByCodeFrom(code: String): List<RelConfigEntity>

    @Query("select * from rel_config where class_code_to = :code")
    suspend fun getConfigByCodeTo(code: String): List<RelConfigEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insConfig(vararg config: RelConfigEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insConfigs(configs: List<RelConfigEntity>)

    @Delete
    suspend fun delConfig(config: RelConfigEntity)
}