cloudroam
2025-03-03 4cb9946eff3626389ae93feef4250dd3d45fb694
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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>
 
    @Query("""
        SELECT * FROM Code 
        WHERE type LIKE '%' || :keyword || '%' 
        AND pickup = '0'
        ORDER BY time DESC
    """)
    fun getByKeyword(keyword: String): List<Code>
 
    @Query("SELECT * FROM Code WHERE type = :content and code= :code and createtime = :dateString LIMIT 1")
    fun queryByTypeAndCodeAndDate(content: String, code: String, dateString: String): Code
 
 
    @Query("update  Code set pickup = '1' where id=:id")
    fun pickup(id: Long)
}