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.ComponentEntity
import com.ys.bdtp.adm.mvvm.model.db.entity.dict.BasicConfigEntity

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

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

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

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

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

    @Delete
    suspend fun delConfig(config: BasicConfigEntity)
}