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.ComponentConfigEntity

/**
 * component 表访问接口
 *
 * @author bai
 */
@Dao
interface ComponentConfigDao {
    @Query("select * from component_config")
    suspend fun getComponents(): List<ComponentConfigEntity>

    @Query("select * from component_config where id = :id")
    suspend fun getComponentById(id: String): ComponentConfigEntity

    @Query("select * from component_config where class_code = :code")
    suspend fun getComponentByCode(code: String): List<ComponentConfigEntity>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insComponent(vararg comp: ComponentConfigEntity)

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insComponents( comps: List<ComponentConfigEntity>)

    @Delete
    suspend fun delConfig(config: ComponentConfigEntity)
}