package com.tenlionsoft.baselib.core.db.daos;

import com.tenlionsoft.baselib.core.db.beans.FoodCanteenBean;

import java.util.List;

import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

/**
 * 作者: adam
 * 日期: 2022/3/28 - 3:07 下午
 * 邮箱: itgaojian@163.com
 * 描述: 食堂信息表
 */
@Dao
public interface FoodCanteenDao {

    /**
     * 添加消息多个
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insert(FoodCanteenBean... beans);

    /**
     * 批量添加
     */
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void insertAll(List<FoodCanteenBean> beans);

    /**
     * 获取全部
     */
    @Query("SELECT * FROM food_canteen")
    List<FoodCanteenBean> getAllList();

    /**
     * 获取最后一条数据
     */
    @Query("SELECT * FROM food_canteen ORDER BY sync_number DESC LIMIT 1")
    FoodCanteenBean getLastOne();

    /**
     * 根据ID删除数据
     */
    @Query("DELETE  FROM food_canteen WHERE id=:id")
    void deleteById(int id);

    /**
     * 根据UID删除数据
     */
    @Query("DELETE FROM food_canteen WHERE uid=:uid")
    void deleteByUid(String uid);

}
