From 5fc9567cfa6b6beee4f52a9f835f304865d693e1 Mon Sep 17 00:00:00 2001 From: cloudroam <cloudroam> Date: 星期四, 10 四月 2025 18:13:58 +0800 Subject: [PATCH] add: 消息提醒后版本 --- app/src/main/java/com/example/firstapp/database/dao/ReminderDao.kt | 21 +++++++++++++++------ 1 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/example/firstapp/database/dao/ReminderDao.kt b/app/src/main/java/com/example/firstapp/database/dao/ReminderDao.kt index 8c9b629..bf6ca23 100644 --- a/app/src/main/java/com/example/firstapp/database/dao/ReminderDao.kt +++ b/app/src/main/java/com/example/firstapp/database/dao/ReminderDao.kt @@ -1,17 +1,26 @@ package com.example.firstapp.database.dao + import androidx.room.* import com.example.firstapp.database.entity.Reminder import kotlinx.coroutines.flow.Flow @Dao interface ReminderDao { - - @Query("SELECT * FROM reminders ORDER BY type") + @Query("SELECT * FROM reminders ORDER BY createdAt DESC") fun getAllReminders(): Flow<List<Reminder>> - @Insert - fun insert(reminder: Reminder) + @Insert(onConflict = OnConflictStrategy.REPLACE) + suspend fun insertReminder(reminder: Reminder) @Delete - fun delete(reminder: Reminder) -} \ No newline at end of file + suspend fun deleteReminder(reminder: Reminder) + + @Query("DELETE FROM reminders WHERE categoryId = :categoryId") + suspend fun deleteReminderByCategoryId(categoryId: Int) + + @Query("SELECT * FROM reminders WHERE categoryId = :categoryId") + suspend fun getReminderByCategoryId(categoryId: Int): Reminder? + + @Query("DELETE FROM reminders") + suspend fun deleteAllReminders() +} \ No newline at end of file -- Gitblit v1.9.3