cloudroam
2025-04-10 5fc9567cfa6b6beee4f52a9f835f304865d693e1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.example.firstapp.database.dao
 
import androidx.room.*
import com.example.firstapp.database.entity.ReminderRecord
import kotlinx.coroutines.flow.Flow
 
@Dao
interface ReminderRecordDao {
    @Query("SELECT * FROM reminder_records ORDER BY createdAt DESC")
    fun getAllRecords(): Flow<List<ReminderRecord>>
 
    @Query("SELECT * FROM reminder_records WHERE status = :status ORDER BY createdAt DESC")
    fun getRecordsByStatus(status: Int): Flow<List<ReminderRecord>>
 
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertRecord(record: ReminderRecord): Long
 
    @Update
    suspend fun updateRecord(record: ReminderRecord)
 
    @Delete
    suspend fun deleteRecord(record: ReminderRecord)
 
    @Query("DELETE FROM reminder_records WHERE categoryId = :categoryId")
    suspend fun deleteRecordsByCategoryId(categoryId: Int)
 
    @Query("UPDATE reminder_records SET status = :status WHERE id = :recordId")
    suspend fun updateRecordStatus(recordId: Long, status: Int)
 
    @Query("SELECT COUNT(*) FROM reminder_records WHERE status = :status")
    suspend fun getUnreadCount(status: Int): Int