mirror of
https://github.com/jfoucry/Pilldroid.git
synced 2024-11-22 04:29:22 +01:00
Add Room prescription database amangement
This commit is contained in:
parent
3e38c7223c
commit
a98601c8b0
3 changed files with 67 additions and 0 deletions
13
app/src/main/java/net/foucry/pilldroid/MedicDatabase.java
Normal file
13
app/src/main/java/net/foucry/pilldroid/MedicDatabase.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package net.foucry.pilldroid;
|
||||
|
||||
import android.arch.persistence.root.Database;
|
||||
import android.arch.persistence.root.RoomDatabase;
|
||||
|
||||
import net.foucry.pilldroid.dao.MedicDAO;
|
||||
import net.foucry.pilldroid.model.Medic;
|
||||
|
||||
@Database(entities = {Medic.class}, version = 1)
|
||||
|
||||
public abstract class PilldroidDatabase extends RoomDatabase {
|
||||
public abstract MedicDAO getMedicDAO();
|
||||
}
|
32
app/src/main/java/net/foucry/pilldroid/dao/MedicDAO.java
Normal file
32
app/src/main/java/net/foucry/pilldroid/dao/MedicDAO.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package net.foucry.pilldroid.dao;
|
||||
|
||||
import android.arch.persistence.room.Dao;
|
||||
import android.arch.persistence.room.Delete;
|
||||
import android.arch.persistence.room.Insert;
|
||||
import android.arch.persistence.room.Update;
|
||||
import net.foucry.pilldroid.models.Medic;
|
||||
|
||||
import android.arch.persistence.room.Query;
|
||||
import java.util.list;
|
||||
|
||||
@Dao
|
||||
public interface MedicDAO {
|
||||
@Insert
|
||||
public void insert(Medic... medics);
|
||||
@Upfdate
|
||||
public void update(Medic... medics);
|
||||
@Delete
|
||||
public void delete(Medic medic);
|
||||
}
|
||||
|
||||
@Query("SELECT * FROM medics")
|
||||
public List<Medic> getMedics();
|
||||
|
||||
@Query("SELECT * FROM medics WHERE id = :id")
|
||||
public Medic getMedicBy(Long id);
|
||||
|
||||
@Query("SELECT * FROM medics WHERE cip13 = :cip13")
|
||||
public Medic getMedicByCIP13(String cip13);
|
||||
|
||||
@Query("SELECT count(*) FROM medics")
|
||||
public int getMedicCount();
|
22
app/src/main/java/net/foucry/pilldroid/models/Medic.java
Normal file
22
app/src/main/java/net/foucry/pilldroid/models/Medic.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package net.foucry.pilldroid.models;
|
||||
|
||||
import android.arch.persitence.room.Entity;
|
||||
import android.arch.persitence.room.PrimaryKey;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
@Entity(tableName = "medics")
|
||||
public class medic {
|
||||
@PrimaryKey
|
||||
@NonNull private Long id;
|
||||
private String cis;
|
||||
private String cip13;
|
||||
private String name;
|
||||
private String administration_mode;
|
||||
private String presentation;
|
||||
private Long stock;
|
||||
private Long take;
|
||||
private Int warning;
|
||||
private Int alert;
|
||||
private Long last_update;
|
||||
}
|
||||
|
Loading…
Reference in a new issue