package com.bgycc.smartcanteen.data.dao; import androidx.lifecycle.LiveData; import androidx.room.Dao; import androidx.room.Insert; import androidx.room.OnConflictStrategy; import androidx.room.Query; import androidx.room.Update; import com.bgycc.smartcanteen.entity.Command; import java.util.List; @Dao public interface CommandDao { // 搜索所有未完成的指令(0为false) @Query("select * from command where finish == 0 order by id asc") LiveData<List<Command>> queryUndoneCommand(); @Insert(onConflict = OnConflictStrategy.REPLACE) long insertCommand(Command command); @Update(onConflict = OnConflictStrategy.REPLACE) int updateCommand(Command command); @Query("select count(*) from command") int countOldData(); // 删除执行完毕的指令 @Query("delete from command where id in " + "(select id from command order by id asc limit :limit)") int clearOldData(int limit); }