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 androidx.room.Update
import com.ys.bdtp.adm.mvvm.model.db.entity.UserEntity

@Dao
interface UserDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insertUser(vararg user: UserEntity)

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

    @Query("select * from user")
    fun queryUsers(): List<UserEntity>

    @Query("select * from user where id = :id")
    fun queryUserById(id: String): UserEntity

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

    @Update
    fun updateUser(user: UserEntity)

    @Delete
    fun deleteUser(user: UserEntity)
}