This commit is contained in:
2026-02-27 12:50:54 +03:00
commit c6c8897cb4
105 changed files with 2935 additions and 0 deletions

1
domain/domain/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,37 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("org.jetbrains.kotlin.android")
id("com.google.dagger.hilt.android")
id("com.google.devtools.ksp")
}
android {
compileSdk = Config.SdkVersion.COMPILE
namespace = "com.testappbank.test"
defaultConfig {
minSdk = Config.SdkVersion.MIN
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("proguard-rules.pro")
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}
dependencies {
implementation(project(":domain:domain_impl"))
implementation(fileTree("dir" to "libs", "include" to listOf("*.jar")))
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
coreLibraryDesugaring(libs.desugar.jdk.libs)
}

21
domain/domain/proguard-rules.pro vendored Normal file
View 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.kts.kts.
#
# 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

View File

@@ -0,0 +1,14 @@
package com.testapp.domain.domain.gatway
import com.testapp.domain.domain.models.ActionResult
import com.testapp.domain.domain.models.Weather
import kotlinx.coroutines.flow.Flow
interface WeatherGateWay {
suspend fun getWeather(id: String): Weather
suspend fun saveWeather(weather:Weather )
suspend fun subscribeForWeatherList(): Flow<List<Weather>>
suspend fun requestNewWeatherForPlace(placeName: String): ActionResult<Weather>
}

View File

@@ -0,0 +1,8 @@
package com.testapp.domain.domain.models
sealed class ActionResult<out Data> {
class Success<Data>(val data: Data) : ActionResult<Data>()
class Error(val reason: Throwable? = null) : ActionResult<Nothing>()
}

View File

@@ -0,0 +1,29 @@
package com.testapp.domain.domain.models
import java.util.Date
data class Weather(
val id: String,
val location: String,
val date: Date,
val temperature: Double
) {
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as Weather
if (id != other.id) return false
if (location != other.location) return false
if (date != other.date) return false
if (temperature != other.temperature) return false
return true
}
override fun hashCode(): Int {
return id.hashCode()
}
}

View File

@@ -0,0 +1,9 @@
package com.testapp.domain.domain.usecase
import com.testapp.domain.domain.models.Weather
interface GetWeather {
suspend fun getWeather(id:String):Weather
}

View File

@@ -0,0 +1,11 @@
package com.testapp.domain.domain.usecase
import com.testapp.domain.domain.models.Weather
import kotlinx.coroutines.flow.Flow
interface GetWeatherList {
suspend fun subscribeForWeatherList(): Flow<List<Weather>>
}

View File

@@ -0,0 +1,10 @@
package com.testapp.domain.domain.usecase
import com.testapp.domain.domain.models.ActionResult
import com.testapp.domain.domain.models.Weather
interface RequestNewWeather {
suspend fun requestNewWeatherForPlace(placeName: String): ActionResult<Weather>
}

View File

@@ -0,0 +1,10 @@
package com.testapp.domain.domain.usecase
import com.testapp.domain.domain.models.ActionResult
import com.testapp.domain.domain.models.Weather
interface SaveWeather {
suspend fun saveWeather(weather: Weather)
}

1
domain/domain_impl/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/build

View File

@@ -0,0 +1,37 @@
plugins {
id("com.android.library")
id("kotlin-android")
id("org.jetbrains.kotlin.android")
id("com.google.dagger.hilt.android")
id("com.google.devtools.ksp")
}
android {
compileSdk = Config.SdkVersion.COMPILE
namespace = "com.testappbank.test"
defaultConfig {
minSdk = Config.SdkVersion.MIN
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("proguard-rules.pro")
}
compileOptions {
isCoreLibraryDesugaringEnabled = true
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
}
dependencies {
implementation(fileTree("dir" to "libs", "include" to listOf("*.jar")))
implementation(project(":domain:domain"))
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
coreLibraryDesugaring(libs.desugar.jdk.libs)
}

View File

@@ -0,0 +1,16 @@
package com.testapp.domain.usecase
import com.testapp.domain.domain.gatway.WeatherGateWay
import com.testapp.domain.domain.models.Weather
import com.testapp.domain.domain.usecase.GetWeather
import javax.inject.Inject
class GetWeatherImpl @Inject constructor(
private val gateWay: WeatherGateWay,
) : GetWeather {
override suspend fun getWeather(id: String): Weather =
gateWay.getWeather(id)
}

View File

@@ -0,0 +1,16 @@
package com.testapp.domain.usecase
import com.testapp.domain.domain.gatway.WeatherGateWay
import com.testapp.domain.domain.models.Weather
import com.testapp.domain.domain.usecase.GetWeatherList
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
class GetWeatherListImpl @Inject constructor(
private val gateWay: WeatherGateWay,
) : GetWeatherList {
override suspend fun subscribeForWeatherList(): Flow<List<Weather>> =
gateWay.subscribeForWeatherList()
}

View File

@@ -0,0 +1,17 @@
package com.testapp.domain.usecase
import com.testapp.domain.domain.gatway.WeatherGateWay
import com.testapp.domain.domain.models.ActionResult
import com.testapp.domain.domain.models.Weather
import com.testapp.domain.domain.usecase.RequestNewWeather
import javax.inject.Inject
class RequestNewWeatherImpl @Inject constructor(
private val gateWay: WeatherGateWay,
) : RequestNewWeather {
override suspend fun requestNewWeatherForPlace(placeName: String): ActionResult<Weather> =
gateWay.requestNewWeatherForPlace(placeName)
}

View File

@@ -0,0 +1,17 @@
package com.testapp.domain.usecase
import com.testapp.domain.domain.gatway.WeatherGateWay
import com.testapp.domain.domain.models.ActionResult
import com.testapp.domain.domain.models.Weather
import com.testapp.domain.domain.usecase.SaveWeather
import javax.inject.Inject
class SaveWeatherImpl @Inject constructor(
val gateWay: WeatherGateWay
) : SaveWeather {
override suspend fun saveWeather(weather: Weather) {
gateWay.saveWeather(weather)
}
}