diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
index 0fc3113..69e8615 100644
--- a/.idea/kotlinc.xml
+++ b/.idea/kotlinc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/build.gradle.kts b/app/build.gradle.kts
index 890e4c0..de7fe54 100644
--- a/app/build.gradle.kts
+++ b/app/build.gradle.kts
@@ -1,6 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
+ id("com.google.devtools.ksp")
}
android {
@@ -67,4 +68,12 @@ dependencies {
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
+
+ // Room
+ val room_version = "2.5.2"
+ implementation("androidx.room:room-runtime:$room_version")
+ annotationProcessor("androidx.room:room-compiler:$room_version")
+ ksp("androidx.room:room-compiler:$room_version")
+ implementation("androidx.room:room-ktx:$room_version")
+ implementation("androidx.room:room-paging:$room_version")
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mobileapp/database/MobileAppDataBase.kt b/app/src/main/java/com/example/mobileapp/database/MobileAppDataBase.kt
new file mode 100644
index 0000000..239ccc7
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/MobileAppDataBase.kt
@@ -0,0 +1,11 @@
+package com.example.mobileapp.database
+
+import androidx.room.Database
+import androidx.room.RoomDatabase
+import com.example.mobileapp.database.entities.Mail
+import com.example.mobileapp.database.entities.Story
+import com.example.mobileapp.database.entities.User
+
+@Database(entities = [User::class, Story::class, Mail::class], version = 1, exportSchema = false)
+abstract class MobileAppDataBase : RoomDatabase() {
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mobileapp/database/dao/MailDao.kt b/app/src/main/java/com/example/mobileapp/database/dao/MailDao.kt
new file mode 100644
index 0000000..a08670e
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/dao/MailDao.kt
@@ -0,0 +1,12 @@
+package com.example.mobileapp.database.dao
+
+import androidx.room.Dao
+import androidx.room.Query
+import com.example.mobileapp.database.entities.Mail
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface MailDao {
+ @Query("select * from mails")
+ fun getAll(): Flow>
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mobileapp/database/dao/StoryDao.kt b/app/src/main/java/com/example/mobileapp/database/dao/StoryDao.kt
new file mode 100644
index 0000000..057de44
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/dao/StoryDao.kt
@@ -0,0 +1,12 @@
+package com.example.mobileapp.database.dao
+
+import androidx.room.Dao
+import androidx.room.Query
+import com.example.mobileapp.database.entities.Story
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface StoryDao {
+ @Query("select * from stories")
+ fun getAll(): Flow>
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mobileapp/database/dao/UserDao.kt b/app/src/main/java/com/example/mobileapp/database/dao/UserDao.kt
new file mode 100644
index 0000000..a5ceafc
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/dao/UserDao.kt
@@ -0,0 +1,12 @@
+package com.example.mobileapp.database.dao
+
+import androidx.room.Dao
+import androidx.room.Query
+import com.example.mobileapp.database.entities.User
+import kotlinx.coroutines.flow.Flow
+
+@Dao
+interface UserDao {
+ @Query("select * from users")
+ fun getAll():Flow>
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mobileapp/database/entities/Mail.kt b/app/src/main/java/com/example/mobileapp/database/entities/Mail.kt
new file mode 100644
index 0000000..ba7eb54
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/entities/Mail.kt
@@ -0,0 +1,31 @@
+package com.example.mobileapp.database.entities
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.PrimaryKey
+
+@Entity(
+ tableName = "mails",
+ foreignKeys = [
+ ForeignKey(
+ entity = User::class,
+ parentColumns = ["id"],
+ childColumns = ["user_id"],
+ onDelete = ForeignKey.RESTRICT,
+ onUpdate = ForeignKey.RESTRICT
+ )
+ ]
+)
+data class Mail(
+ @PrimaryKey(autoGenerate = true)
+ var id: Int?,
+ @ColumnInfo(name = "message")
+ val message: String,
+ @ColumnInfo(name="user_id")
+ val userId: Int
+){
+ override fun hashCode(): Int {
+ return id ?: -1
+ }
+}
diff --git a/app/src/main/java/com/example/mobileapp/database/entities/Story.kt b/app/src/main/java/com/example/mobileapp/database/entities/Story.kt
new file mode 100644
index 0000000..815658d
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/entities/Story.kt
@@ -0,0 +1,36 @@
+package com.example.mobileapp.database.entities
+
+import android.graphics.Bitmap
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.ForeignKey
+import androidx.room.PrimaryKey
+
+@Entity(
+ tableName = "stories",
+ foreignKeys = [
+ ForeignKey(
+ entity = User::class,
+ parentColumns = ["id"],
+ childColumns = ["user_id"],
+ onDelete = ForeignKey.RESTRICT,
+ onUpdate = ForeignKey.RESTRICT
+ )
+ ]
+)
+data class Story(
+ @PrimaryKey(autoGenerate = true)
+ val id: Int?,
+ @ColumnInfo(name = "title")
+ val title: String,
+ @ColumnInfo(name = "description")
+ val description: String,
+ @ColumnInfo(name = "cover")
+ val cover: Bitmap,
+ @ColumnInfo(name="user_id")
+ val userId: Int
+){
+ override fun hashCode(): Int {
+ return id ?: -1
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/mobileapp/database/entities/User.kt b/app/src/main/java/com/example/mobileapp/database/entities/User.kt
new file mode 100644
index 0000000..7337a99
--- /dev/null
+++ b/app/src/main/java/com/example/mobileapp/database/entities/User.kt
@@ -0,0 +1,21 @@
+package com.example.mobileapp.database.entities
+
+import androidx.room.ColumnInfo
+import androidx.room.Entity
+import androidx.room.PrimaryKey
+
+@Entity(tableName = "users")
+data class User(
+ @PrimaryKey(autoGenerate = true)
+ var id: Int?,
+ @ColumnInfo(name = "login")
+ val login: String,
+ @ColumnInfo(name = "password")
+ val password: String,
+ @ColumnInfo(name = "email")
+ val email: String,
+){
+ override fun hashCode(): Int {
+ return id ?: -1
+ }
+}
diff --git a/build.gradle.kts b/build.gradle.kts
index 9861456..bd1eb8a 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -2,4 +2,5 @@
plugins {
id("com.android.application") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
+ id("com.google.devtools.ksp") version "1.8.20-1.0.11" apply false
}
\ No newline at end of file