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

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.config.RelationConfigEntity

/**
 * 表 relation_config Dao
 */
@Dao
interface RelationConfigDao {
    @Query("select * from relation_config")
    suspend fun getConfigs(): List<RelationConfigEntity>

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

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

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

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

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

    @Delete
    suspend fun delConfig(config: RelationConfigEntity)
}