Proyectos de Subversion Android Microlearning - Inconcert

Rev

Rev 14 | Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 gabriel 1
package com.cesams.twogetskills.inconcert.dao;
2
 
3
import androidx.room.Dao;
4
import androidx.room.Insert;
5
import androidx.room.Query;
6
import androidx.room.Update;
7
 
8
import com.cesams.twogetskills.inconcert.entity.Capsule;
9
import com.cesams.twogetskills.inconcert.room.ResultCount;
10
 
11
import java.util.List;
12
 
13
@Dao
14
public interface CapsuleDao {
15
 
16
    @Query("SELECT * FROM tb_capsules ORDER BY position, name")
17
    List<Capsule> selectAll();
18
 
19
    @Query("SELECT * FROM tb_capsules WHERE topic_uuid = :topicUuid ORDER BY position, name")
20
    List<Capsule> selectAllByTopicUuid(String topicUuid);
21
 
22
    @Query("SELECT * FROM tb_capsules WHERE topic_uuid = :topicUuid ORDER BY added_on DESC")
23
    List<Capsule> selectAllByTopicUuidandOrder(String topicUuid);
24
 
25
 
26
    @Query("SELECT * FROM tb_capsules WHERE uuid = :uuid LIMIT 1")
27
    Capsule selectByUuid(String uuid);
28
 
29
    @Query("SELECT COUNT(*) AS count FROM tb_capsules WHERE topic_uuid = :topicUuid LIMIT 1")
30
    ResultCount getCountByTopicUuid(String topicUuid);
31
 
32
    @Query("SELECT COUNT(*) AS count FROM tb_capsules LIMIT 1")
33
    ResultCount getCount();
34
 
35
    @Insert
36
    void insert(Capsule capsule);
37
 
38
 
39
    @Update
40
    void update(Capsule capsule);
41
 
42
    @Query("DELETE FROM tb_capsules WHERE uuid = :uuid")
43
    void removeByUuid(String uuid);
44
 
45
    @Query("DELETE FROM tb_capsules")
46
    void removeAll();
47
 
48
}