diff --git a/app/src/main/java/me/zobrist/tichucounter/data/DaoBase.kt b/app/src/main/java/me/zobrist/tichucounter/data/DaoBase.kt new file mode 100644 index 0000000..563f3d2 --- /dev/null +++ b/app/src/main/java/me/zobrist/tichucounter/data/DaoBase.kt @@ -0,0 +1,17 @@ +package me.zobrist.tichucounter.data + +import androidx.room.* +import kotlinx.coroutines.flow.Flow + +@Dao +interface DaoBase { + + @Insert + fun insert(entity: T): Long + + @Update + fun update(entity: T) + + @Delete + fun delete(entity: T) +} \ No newline at end of file diff --git a/app/src/main/java/me/zobrist/tichucounter/data/GameDao.kt b/app/src/main/java/me/zobrist/tichucounter/data/GameDao.kt index 808b165..d4bf597 100644 --- a/app/src/main/java/me/zobrist/tichucounter/data/GameDao.kt +++ b/app/src/main/java/me/zobrist/tichucounter/data/GameDao.kt @@ -5,7 +5,7 @@ import kotlinx.coroutines.flow.Flow @Dao -interface GameDao { +interface GameDao: DaoBase { @Query("SELECT * FROM game") fun getAll(): Flow> @@ -22,12 +22,4 @@ interface GameDao { @Query("UPDATE game SET active = 0 WHERE uid is not :gameId;") fun setOthersInactive(gameId: Long) - @Insert - fun insert(game: Game): Long - - @Update - fun update(game: Game) - - @Delete - fun delete(round: Game) } \ No newline at end of file diff --git a/app/src/main/java/me/zobrist/tichucounter/data/RoundDao.kt b/app/src/main/java/me/zobrist/tichucounter/data/RoundDao.kt index 15a433b..aface1a 100644 --- a/app/src/main/java/me/zobrist/tichucounter/data/RoundDao.kt +++ b/app/src/main/java/me/zobrist/tichucounter/data/RoundDao.kt @@ -7,7 +7,7 @@ import androidx.room.Query import kotlinx.coroutines.flow.Flow @Dao -interface RoundDao { +interface RoundDao: DaoBase { @Query("SELECT * FROM round") fun getAll(): Flow> @@ -18,6 +18,4 @@ interface RoundDao { @Insert fun insertAll(vararg rounds: Round) - @Delete - fun delete(round: Round) } \ No newline at end of file