Refactoring db module structure
This commit is contained in:
@@ -70,6 +70,7 @@ dependencies {
|
|||||||
implementation(projects.core.common)
|
implementation(projects.core.common)
|
||||||
implementation(projects.core.config)
|
implementation(projects.core.config)
|
||||||
implementation(projects.core.navigation)
|
implementation(projects.core.navigation)
|
||||||
|
implementation(projects.core.database.impl)
|
||||||
implementation(projects.core.ui)
|
implementation(projects.core.ui)
|
||||||
|
|
||||||
implementation(projects.feature.splash)
|
implementation(projects.feature.splash)
|
||||||
|
|||||||
28
core/database/api/build.gradle.kts
Normal file
28
core/database/api/build.gradle.kts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
plugins {
|
||||||
|
alias(libs.plugins.android.library)
|
||||||
|
alias(libs.plugins.kotlin.android)
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
namespace = "ru.fincode.tsudesk.core.database.api"
|
||||||
|
compileSdk = libs.versions.compileSdk.get().toInt()
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdk = libs.versions.minSdk.get().toInt()
|
||||||
|
consumerProguardFiles("consumer-rules.pro")
|
||||||
|
}
|
||||||
|
|
||||||
|
val jvm = JavaVersion.toVersion(libs.versions.jvmTarget.get())
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = jvm
|
||||||
|
targetCompatibility = jvm
|
||||||
|
}
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = jvm.toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(libs.room.runtime)
|
||||||
|
api(libs.kotlinx.coroutines.core)
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.fincode.tsudesk.core.database.schedule
|
package ru.fincode.tsudesk.core.database.api.schedule
|
||||||
|
|
||||||
object Constants {
|
object Constants {
|
||||||
const val SCHEDULE_TABLE = "schedule_cache"
|
const val SCHEDULE_TABLE = "schedule_cache"
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
package ru.fincode.tsudesk.core.database.schedule
|
package ru.fincode.tsudesk.core.database.api.schedule
|
||||||
|
|
||||||
import androidx.room.Entity
|
import androidx.room.Entity
|
||||||
import androidx.room.Index
|
import androidx.room.Index
|
||||||
import androidx.room.PrimaryKey
|
import androidx.room.PrimaryKey
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.COL_SCHEDULE_KEY
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.COL_SCHEDULE_KEY
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.LESSON_TABLE
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.LESSON_TABLE
|
||||||
|
|
||||||
@Entity(
|
@Entity(
|
||||||
tableName = LESSON_TABLE, indices = [Index(value = [COL_SCHEDULE_KEY])]
|
tableName = LESSON_TABLE,
|
||||||
|
indices = [Index(value = [COL_SCHEDULE_KEY])]
|
||||||
)
|
)
|
||||||
data class LessonCacheEntity(
|
data class LessonCacheEntity(
|
||||||
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
@PrimaryKey(autoGenerate = true) val id: Long = 0,
|
||||||
@@ -21,4 +22,4 @@ data class LessonCacheEntity(
|
|||||||
val teacher: String,
|
val teacher: String,
|
||||||
val groupIds: List<String>,
|
val groupIds: List<String>,
|
||||||
val type: String
|
val type: String
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package ru.fincode.tsudesk.core.database.api.schedule
|
||||||
|
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.COL_KEY
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.COL_SCHEDULE_KEY
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.LESSON_TABLE
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.SCHEDULE_TABLE
|
||||||
|
|
||||||
|
object Query {
|
||||||
|
|
||||||
|
const val SELECT_LESSON_BY_KEY_QUERY =
|
||||||
|
"SELECT * FROM ${LESSON_TABLE} WHERE ${COL_SCHEDULE_KEY} = :key"
|
||||||
|
|
||||||
|
const val SELECT_SCHEDULE_BY_KEY_QUERY =
|
||||||
|
"SELECT * FROM ${SCHEDULE_TABLE} WHERE `${COL_KEY}` = :key LIMIT 1"
|
||||||
|
|
||||||
|
const val DELETE_LESSON_BY_KEY_QUERY =
|
||||||
|
"DELETE FROM ${LESSON_TABLE} WHERE ${COL_SCHEDULE_KEY} = :key"
|
||||||
|
|
||||||
|
const val DELETE_SCHEDULE_BY_KEY_QUERY =
|
||||||
|
"DELETE FROM ${SCHEDULE_TABLE} WHERE `${COL_KEY}` = :key"
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package ru.fincode.tsudesk.core.database.api.schedule
|
||||||
|
|
||||||
|
import androidx.room.Entity
|
||||||
|
import androidx.room.PrimaryKey
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.SCHEDULE_TABLE
|
||||||
|
|
||||||
|
@Entity(tableName = SCHEDULE_TABLE)
|
||||||
|
data class ScheduleCacheEntity(
|
||||||
|
@PrimaryKey
|
||||||
|
val key: String, // "group:220631" | "teacher:ФИО"
|
||||||
|
val timestamp: Long
|
||||||
|
)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.fincode.tsudesk.core.database.schedule
|
package ru.fincode.tsudesk.core.database.api.schedule
|
||||||
|
|
||||||
import androidx.room.Dao
|
import androidx.room.Dao
|
||||||
import androidx.room.Insert
|
import androidx.room.Insert
|
||||||
@@ -6,11 +6,10 @@ import androidx.room.OnConflictStrategy
|
|||||||
import androidx.room.Query
|
import androidx.room.Query
|
||||||
import androidx.room.Transaction
|
import androidx.room.Transaction
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Query.DELETE_LESSONS_BY_KEY
|
import ru.fincode.tsudesk.core.database.api.schedule.Query.DELETE_LESSON_BY_KEY_QUERY
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Query.DELETE_SCHEDULE_BY_KEY
|
import ru.fincode.tsudesk.core.database.api.schedule.Query.DELETE_SCHEDULE_BY_KEY_QUERY
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Query.SELECT_LESSONS_BY_KEY_QUERY
|
import ru.fincode.tsudesk.core.database.api.schedule.Query.SELECT_LESSON_BY_KEY_QUERY
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Query.SELECT_SCHEDULE_BY_KEY_QUERY
|
import ru.fincode.tsudesk.core.database.api.schedule.Query.SELECT_SCHEDULE_BY_KEY_QUERY
|
||||||
|
|
||||||
|
|
||||||
@Dao
|
@Dao
|
||||||
interface ScheduleDao {
|
interface ScheduleDao {
|
||||||
@@ -18,13 +17,13 @@ interface ScheduleDao {
|
|||||||
@Query(SELECT_SCHEDULE_BY_KEY_QUERY)
|
@Query(SELECT_SCHEDULE_BY_KEY_QUERY)
|
||||||
fun observeSchedule(key: String): Flow<ScheduleCacheEntity?>
|
fun observeSchedule(key: String): Flow<ScheduleCacheEntity?>
|
||||||
|
|
||||||
@Query(SELECT_LESSONS_BY_KEY_QUERY)
|
@Query(SELECT_LESSON_BY_KEY_QUERY)
|
||||||
fun observeLessons(key: String): Flow<List<LessonCacheEntity>>
|
fun observeLessons(key: String): Flow<List<LessonCacheEntity>>
|
||||||
|
|
||||||
@Query(SELECT_SCHEDULE_BY_KEY_QUERY)
|
@Query(SELECT_SCHEDULE_BY_KEY_QUERY)
|
||||||
suspend fun getSchedule(key: String): ScheduleCacheEntity?
|
suspend fun getSchedule(key: String): ScheduleCacheEntity?
|
||||||
|
|
||||||
@Query(SELECT_LESSONS_BY_KEY_QUERY)
|
@Query(SELECT_LESSON_BY_KEY_QUERY)
|
||||||
suspend fun getLessons(key: String): List<LessonCacheEntity>
|
suspend fun getLessons(key: String): List<LessonCacheEntity>
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
@@ -33,10 +32,10 @@ interface ScheduleDao {
|
|||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertLessons(lessons: List<LessonCacheEntity>)
|
suspend fun insertLessons(lessons: List<LessonCacheEntity>)
|
||||||
|
|
||||||
@Query(DELETE_LESSONS_BY_KEY)
|
@Query(DELETE_LESSON_BY_KEY_QUERY)
|
||||||
suspend fun deleteLessonsByKey(key: String)
|
suspend fun deleteLessonsByKey(key: String)
|
||||||
|
|
||||||
@Query(DELETE_SCHEDULE_BY_KEY)
|
@Query(DELETE_SCHEDULE_BY_KEY_QUERY)
|
||||||
suspend fun deleteScheduleByKey(key: String)
|
suspend fun deleteScheduleByKey(key: String)
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
@@ -51,8 +50,8 @@ interface ScheduleDao {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Transaction
|
@Transaction
|
||||||
suspend fun removeSchedule(key: String) {
|
suspend fun clearSchedule(key: String) {
|
||||||
deleteLessonsByKey(key)
|
deleteLessonsByKey(key)
|
||||||
deleteScheduleByKey(key)
|
deleteScheduleByKey(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "ru.fincode.tsudesk.core.database"
|
namespace = "ru.fincode.tsudesk.core.database.impl"
|
||||||
compileSdk = libs.versions.compileSdk.get().toInt()
|
compileSdk = libs.versions.compileSdk.get().toInt()
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
@@ -35,6 +35,9 @@ android {
|
|||||||
}
|
}
|
||||||
kapt {
|
kapt {
|
||||||
correctErrorTypes = true
|
correctErrorTypes = true
|
||||||
|
arguments {
|
||||||
|
arg("room.schemaLocation", "$projectDir/schemas")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(libs.room.runtime)
|
implementation(libs.room.runtime)
|
||||||
@@ -43,4 +46,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation(libs.hilt.android)
|
implementation(libs.hilt.android)
|
||||||
kapt(libs.hilt.compiler)
|
kapt(libs.hilt.compiler)
|
||||||
|
|
||||||
|
implementation(projects.core.database.api)
|
||||||
}
|
}
|
||||||
0
core/database/impl/consumer-rules.pro
Normal file
0
core/database/impl/consumer-rules.pro
Normal file
21
core/database/impl/proguard-rules.pro
vendored
Normal file
21
core/database/impl/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 2,
|
||||||
|
"identityHash": "3d269ca42c7bee3550ec1498f99f51f1",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "schedule_cache",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`key` TEXT NOT NULL, `timestamp` INTEGER NOT NULL, PRIMARY KEY(`key`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "key",
|
||||||
|
"columnName": "key",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "timestamp",
|
||||||
|
"columnName": "timestamp",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"key"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [],
|
||||||
|
"foreignKeys": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "lesson_cache",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `scheduleKey` TEXT NOT NULL, `date` TEXT NOT NULL, `time` TEXT NOT NULL, `name` TEXT NOT NULL, `typeName` TEXT NOT NULL, `room` TEXT NOT NULL, `teacher` TEXT NOT NULL, `groupIds` TEXT NOT NULL, `type` TEXT NOT NULL)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "scheduleKey",
|
||||||
|
"columnName": "scheduleKey",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "date",
|
||||||
|
"columnName": "date",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "time",
|
||||||
|
"columnName": "time",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "typeName",
|
||||||
|
"columnName": "typeName",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "room",
|
||||||
|
"columnName": "room",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "teacher",
|
||||||
|
"columnName": "teacher",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "groupIds",
|
||||||
|
"columnName": "groupIds",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_lesson_cache_scheduleKey",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"scheduleKey"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_lesson_cache_scheduleKey` ON `${TABLE_NAME}` (`scheduleKey`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"views": [],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '3d269ca42c7bee3550ec1498f99f51f1')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package ru.fincode.core.database.impl
|
||||||
|
|
||||||
|
import androidx.room.Database
|
||||||
|
import androidx.room.RoomDatabase
|
||||||
|
import androidx.room.TypeConverters
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.LessonCacheEntity
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.ScheduleCacheEntity
|
||||||
|
import ru.fincode.tsudesk.core.database.api.schedule.ScheduleDao
|
||||||
|
|
||||||
|
@Database(
|
||||||
|
entities = [
|
||||||
|
ScheduleCacheEntity::class,
|
||||||
|
LessonCacheEntity::class
|
||||||
|
],
|
||||||
|
version = 2,
|
||||||
|
exportSchema = true
|
||||||
|
)
|
||||||
|
@TypeConverters(StringListConverter::class)
|
||||||
|
abstract class AppDatabase : RoomDatabase() {
|
||||||
|
|
||||||
|
abstract fun scheduleCacheDao(): ScheduleDao
|
||||||
|
}
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
package ru.fincode.tsudesk.core.database
|
package ru.fincode.core.database.impl
|
||||||
|
|
||||||
import androidx.room.TypeConverter
|
import androidx.room.TypeConverter
|
||||||
|
|
||||||
class StringListConverter {
|
class StringListConverter {
|
||||||
|
|
||||||
private val separator = "||"
|
private companion object {
|
||||||
|
const val SEPARATOR = "||"
|
||||||
|
}
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun fromList(list: List<String>?): String =
|
fun fromList(list: List<String>?): String =
|
||||||
list
|
list?.joinToString(SEPARATOR).orEmpty()
|
||||||
?.joinToString(separator = separator)
|
|
||||||
.orEmpty()
|
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun toList(value: String?): List<String> =
|
fun toList(value: String?): List<String> =
|
||||||
value
|
value
|
||||||
?.takeIf { it.isNotBlank() }
|
?.takeIf { it.isNotBlank() }
|
||||||
?.split(separator)
|
?.split(SEPARATOR)
|
||||||
.orEmpty()
|
?: emptyList()
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package ru.fincode.tsudesk.core.database.builder
|
package ru.fincode.core.database.impl.builder
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.room.Room
|
import androidx.room.Room
|
||||||
import ru.fincode.tsudesk.core.database.AppDatabase
|
import ru.fincode.core.database.impl.AppDatabase
|
||||||
|
|
||||||
object AppDatabaseBuilder {
|
object AppDatabaseBuilder {
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package ru.fincode.tsudesk.core.database.di
|
package ru.fincode.core.database.impl.di
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
@@ -6,9 +6,9 @@ import dagger.Provides
|
|||||||
import dagger.hilt.InstallIn
|
import dagger.hilt.InstallIn
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import dagger.hilt.components.SingletonComponent
|
import dagger.hilt.components.SingletonComponent
|
||||||
import ru.fincode.tsudesk.core.database.AppDatabase
|
import ru.fincode.core.database.impl.AppDatabase
|
||||||
import ru.fincode.tsudesk.core.database.builder.AppDatabaseBuilder
|
import ru.fincode.core.database.impl.builder.AppDatabaseBuilder
|
||||||
import ru.fincode.tsudesk.core.database.schedule.ScheduleDao
|
import ru.fincode.tsudesk.core.database.api.schedule.ScheduleDao
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Module
|
@Module
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package ru.fincode.tsudesk.core.database
|
|
||||||
|
|
||||||
import androidx.room.Database
|
|
||||||
import androidx.room.RoomDatabase
|
|
||||||
import androidx.room.TypeConverters
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.LessonCacheEntity
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.ScheduleCacheEntity
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.ScheduleDao
|
|
||||||
|
|
||||||
@TypeConverters(StringListConverter::class)
|
|
||||||
@Database(
|
|
||||||
entities = [
|
|
||||||
// schedule feature
|
|
||||||
ScheduleCacheEntity::class,
|
|
||||||
LessonCacheEntity::class,
|
|
||||||
|
|
||||||
// future:
|
|
||||||
// NewsEntity::class,
|
|
||||||
// GradeEntity::class,
|
|
||||||
],
|
|
||||||
version = 2,
|
|
||||||
exportSchema = false
|
|
||||||
)
|
|
||||||
abstract class AppDatabase : RoomDatabase() {
|
|
||||||
abstract fun scheduleCacheDao(): ScheduleDao
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package ru.fincode.tsudesk.core.database.schedule
|
|
||||||
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.COL_KEY
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.COL_SCHEDULE_KEY
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.LESSON_TABLE
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.SCHEDULE_TABLE
|
|
||||||
|
|
||||||
object Query {
|
|
||||||
|
|
||||||
const val SELECT_LESSONS_BY_KEY_QUERY =
|
|
||||||
"SELECT * FROM $LESSON_TABLE WHERE $COL_SCHEDULE_KEY = :key"
|
|
||||||
|
|
||||||
const val SELECT_SCHEDULE_BY_KEY_QUERY =
|
|
||||||
"SELECT * FROM $SCHEDULE_TABLE WHERE $COL_KEY = :key LIMIT 1"
|
|
||||||
|
|
||||||
const val DELETE_LESSONS_BY_KEY =
|
|
||||||
"DELETE FROM $LESSON_TABLE WHERE $COL_SCHEDULE_KEY = :key"
|
|
||||||
|
|
||||||
const val DELETE_SCHEDULE_BY_KEY =
|
|
||||||
"DELETE FROM $SCHEDULE_TABLE WHERE $COL_KEY = :key"
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package ru.fincode.tsudesk.core.database.schedule
|
|
||||||
|
|
||||||
import androidx.room.Entity
|
|
||||||
import androidx.room.PrimaryKey
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.SCHEDULE_TABLE
|
|
||||||
|
|
||||||
@Entity(tableName = SCHEDULE_TABLE)
|
|
||||||
data class ScheduleCacheEntity(
|
|
||||||
@PrimaryKey
|
|
||||||
val key: String, // "group:220631" | "teacher:ФИО"
|
|
||||||
val timestamp: Long
|
|
||||||
)
|
|
||||||
@@ -39,7 +39,6 @@ dependencies {
|
|||||||
// Compose
|
// Compose
|
||||||
implementation(platform(libs.compose.bom))
|
implementation(platform(libs.compose.bom))
|
||||||
implementation(libs.compose.runtime)
|
implementation(libs.compose.runtime)
|
||||||
implementation("androidx.compose.material:material-icons-extended")
|
|
||||||
// Navigation Compose
|
// Navigation Compose
|
||||||
implementation(libs.androidx.navigation.compose)
|
implementation(libs.androidx.navigation.compose)
|
||||||
implementation(libs.androidx.navigation.common)
|
implementation(libs.androidx.navigation.common)
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ dependencies {
|
|||||||
implementation(projects.core.ui)
|
implementation(projects.core.ui)
|
||||||
implementation(projects.core.navigation)
|
implementation(projects.core.navigation)
|
||||||
|
|
||||||
// Data modules used by feature (если feature реально ходит в сеть/бд)
|
|
||||||
implementation(projects.core.network)
|
implementation(projects.core.network)
|
||||||
implementation(projects.core.database)
|
implementation(projects.core.database.api)
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ import kotlinx.coroutines.flow.flow
|
|||||||
import kotlinx.coroutines.flow.flowOf
|
import kotlinx.coroutines.flow.flowOf
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.flow.onStart
|
import kotlinx.coroutines.flow.onStart
|
||||||
import ru.fincode.tsudesk.core.database.schedule.ScheduleDao
|
import ru.fincode.tsudesk.core.database.api.schedule.ScheduleDao
|
||||||
import ru.fincode.tsudesk.feature.schedule.data.datasource.ScheduleLocalDataSource
|
import ru.fincode.tsudesk.feature.schedule.data.datasource.ScheduleLocalDataSource
|
||||||
import ru.fincode.tsudesk.feature.schedule.domain.model.ScheduleEntity
|
import ru.fincode.tsudesk.feature.schedule.domain.model.ScheduleEntity
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package ru.fincode.tsudesk.feature.schedule.data.local
|
package ru.fincode.tsudesk.feature.schedule.data.local
|
||||||
|
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.GROUP_PRE_KEY
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.GROUP_PRE_KEY
|
||||||
import ru.fincode.tsudesk.core.database.schedule.Constants.TEACHER_PRE_KEY
|
import ru.fincode.tsudesk.core.database.api.schedule.Constants.TEACHER_PRE_KEY
|
||||||
import ru.fincode.tsudesk.core.database.schedule.LessonCacheEntity
|
import ru.fincode.tsudesk.core.database.api.schedule.LessonCacheEntity
|
||||||
import ru.fincode.tsudesk.core.database.schedule.ScheduleCacheEntity
|
import ru.fincode.tsudesk.core.database.api.schedule.ScheduleCacheEntity
|
||||||
import ru.fincode.tsudesk.feature.schedule.domain.model.LessonEntity
|
import ru.fincode.tsudesk.feature.schedule.domain.model.LessonEntity
|
||||||
import ru.fincode.tsudesk.feature.schedule.domain.model.LessonType
|
import ru.fincode.tsudesk.feature.schedule.domain.model.LessonType
|
||||||
import ru.fincode.tsudesk.feature.schedule.domain.model.ScheduleEntity
|
import ru.fincode.tsudesk.feature.schedule.domain.model.ScheduleEntity
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ junit = "4.13.2"
|
|||||||
junitVersion = "1.3.0"
|
junitVersion = "1.3.0"
|
||||||
espressoCore = "3.7.0"
|
espressoCore = "3.7.0"
|
||||||
materialVersion = "1.13.0"
|
materialVersion = "1.13.0"
|
||||||
|
junitJunit = "4.13.2"
|
||||||
|
androidxJunit = "1.3.0"
|
||||||
|
espressoCoreVersion = "3.7.0"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
# KotlinX
|
# KotlinX
|
||||||
@@ -77,6 +80,9 @@ room-compiler = { module = "androidx.room:room-compiler", version.ref = "room" }
|
|||||||
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
|
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
|
||||||
compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
|
compose-ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
|
||||||
material = { group = "com.google.android.material", name = "material", version.ref = "materialVersion" }
|
material = { group = "com.google.android.material", name = "material", version.ref = "materialVersion" }
|
||||||
|
junit = { group = "junit", name = "junit", version.ref = "junitJunit" }
|
||||||
|
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidxJunit" }
|
||||||
|
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCoreVersion" }
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||||
|
|||||||
@@ -24,11 +24,13 @@ rootProject.name = "TSUDesk"
|
|||||||
include(":app")
|
include(":app")
|
||||||
|
|
||||||
include(":core:common")
|
include(":core:common")
|
||||||
|
include(":core:config")
|
||||||
include(":core:ui")
|
include(":core:ui")
|
||||||
include(":core:navigation")
|
include(":core:navigation")
|
||||||
include(":core:network")
|
include(":core:network")
|
||||||
include(":core:database")
|
|
||||||
include(":core:config")
|
include(":core:database:impl")
|
||||||
|
include(":core:database:api")
|
||||||
|
|
||||||
include(":feature:schedule")
|
include(":feature:schedule")
|
||||||
include(":feature:news")
|
include(":feature:news")
|
||||||
|
|||||||
Reference in New Issue
Block a user