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

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.framework.mvvm.model.db.entity.UserEntity

@Dao
interface UserDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insUser(vararg: UserEntity): Long

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insUsers(users: List<UserEntity>): List<Long>

    @Query("select * from user where user_id =:userId")
    fun getUserByUserId(userId: String): UserEntity

    @Query("select * from user where username =:username and password = :password")
    suspend fun getUser(username: String, password: String): UserEntity?

    @Query("select * from user")
    suspend fun getUsers(): MutableList<UserEntity>

    @Query("select * from user where state = :state")
    suspend fun getUserByState(state: Int): UserEntity

}
