Dao追加, モデル追加

This commit is contained in:
ろむねこ 2024-07-08 11:08:48 +09:00
parent f78b17dfb5
commit 477152e40e
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168
2 changed files with 28 additions and 0 deletions

View File

@ -4,10 +4,12 @@ import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Transaction;
import java.util.List;
import one.nem.kidshift.data.room.entity.HistoryCacheEntity;
import one.nem.kidshift.data.room.model.HistoryWithTask;
@Dao
public interface HistoryCacheDao {
@ -27,6 +29,14 @@ public interface HistoryCacheDao {
@Query("SELECT * FROM history_cache WHERE child_id = :childId")
List<HistoryCacheEntity> getHistoryListByChildId(String childId);
@Transaction
@Query("SELECT * FROM history_cache")
List<HistoryWithTask> getHistoryWithTasks();
@Transaction
@Query("SELECT * FROM history_cache WHERE child_id = :childId")
List<HistoryWithTask> getHistoryWithTasksByChildId(String childId);
@Query("SELECT * FROM history_cache WHERE task_id = :taskId")
List<HistoryCacheEntity> getHistoryListByTaskId(String taskId);

View File

@ -0,0 +1,18 @@
package one.nem.kidshift.data.room.model;
import androidx.room.Embedded;
import androidx.room.Relation;
import one.nem.kidshift.data.room.entity.HistoryCacheEntity;
import one.nem.kidshift.data.room.entity.TaskCacheEntity;
public class HistoryWithTask {
@Embedded
public HistoryCacheEntity history;
@Relation(
parentColumn = "task_id",
entityColumn = "id"
)
public TaskCacheEntity task;
}