package com.unis.model.login_log;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * 登录记录
 * 创建人: mQ
 * 创建时间: 2021/2/5 16:59
 */
@Dao
public interface LoginDao {

    @Query("SELECT * FROM loginlog WHERE name = :name")
    LoginLog getByName(String name);

    @Query("SELECT * FROM loginlog ORDER BY time DESC")
    List<LoginLog> getAll();

    @Query("SELECT name,pwd FROM loginlog ORDER BY time DESC LIMIT 1")
    LogFirst getFirst();

    @Insert
    void insert(LoginLog... users);

    @Update
    void update(LoginLog... users);

    @Delete
    void delete(LoginLog... user);

    @Query("DELETE FROM loginlog")
    void deleteAll();
}
