cloudroam
2025-02-14 2fce91b8c0faf1290d8a35ee022dab3cdbc28a54
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
33
34
35
36
37
38
39
40
41
42
43
44
package com.example.firstapp.database.dao
 
import androidx.room.Dao
import androidx.room.Delete
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.firstapp.database.entity.Code
import com.example.firstapp.database.entity.Msg
import io.reactivex.Completable
 
@Dao
interface CodeDao {
 
    @Insert
     fun insert(code: Code): Long
 
    @Update
     fun update(code: Code)
 
    @Delete
    fun delete(msg: Msg): Completable
 
    @Query("DELETE FROM Code where id=:id")
    fun delete(id: Long)
 
 
    @Query("SELECT * FROM Code WHERE id = :id LIMIT 1")
     fun getCodeById(id: Long): Code?
 
    @Query("SELECT * FROM Code")
     fun getAllCodes(): List<Code>
 
    @Query("SELECT * FROM Code WHERE type = :type")
     fun getCodesByType(type: String): List<Code>
 
 
 
    @Query("DELETE FROM Code WHERE id = :id")
     fun deleteCodeById(id: Long)
 
    @Query("SELECT * FROM Code order by time desc")
    abstract fun getAllCodesDesc():  List<Code>
}