-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #59 from Nexters/refactor/domain-layer
Refactor/layer
- Loading branch information
Showing
224 changed files
with
2,124 additions
and
1,041 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/domain/src/main/AndroidManifest.xml → core/data/auth/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> | ||
</manifest> |
17 changes: 17 additions & 0 deletions
17
core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/di/AuthDataModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.goalpanzi.mission_mate.core.data.auth.di | ||
|
||
import com.goalpanzi.mission_mate.core.data.auth.repository.AuthRepositoryImpl | ||
import com.goalpanzi.mission_mate.core.domain.auth.repository.AuthRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal abstract class AuthDataModule { | ||
|
||
@Binds | ||
abstract fun bindLoginRepository(impl: AuthRepositoryImpl): AuthRepository | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
core/data/auth/src/main/java/com/goalpanzi/mission_mate/core/data/auth/mapper/AuthMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.goalpanzi.mission_mate.core.data.auth.mapper | ||
|
||
import com.goalpanzi.mission_mate.core.data.common.mapper.toModel | ||
import com.goalpanzi.mission_mate.core.domain.auth.model.GoogleLogin | ||
import com.goalpanzi.mission_mate.core.domain.common.model.user.CharacterType | ||
import com.goalpanzi.mission_mate.core.network.model.response.GoogleLoginResponse | ||
|
||
fun GoogleLoginResponse.toModel() : GoogleLogin { | ||
return GoogleLogin( | ||
accessToken = accessToken, | ||
refreshToken = refreshToken, | ||
nickname = nickname, | ||
characterType = characterType?.toModel() ?: CharacterType.RABBIT, | ||
isProfileSet = isProfileSet, | ||
memberId = memberId | ||
) | ||
} |
41 changes: 41 additions & 0 deletions
41
.../src/main/java/com/goalpanzi/mission_mate/core/data/auth/repository/AuthRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.goalpanzi.mission_mate.core.data.auth.repository | ||
|
||
import com.goalpanzi.mission_mate.core.data.auth.mapper.toModel | ||
import com.goalpanzi.mission_mate.core.data.common.handleResult | ||
import com.goalpanzi.mission_mate.core.datastore.datasource.AuthDataSource | ||
import com.goalpanzi.mission_mate.core.domain.auth.repository.AuthRepository | ||
import com.goalpanzi.mission_mate.core.domain.common.DomainResult | ||
import com.goalpanzi.mission_mate.core.domain.common.convert | ||
import com.goalpanzi.mission_mate.core.network.model.request.GoogleLoginRequest | ||
import com.goalpanzi.mission_mate.core.network.service.LoginService | ||
import kotlinx.coroutines.flow.Flow | ||
import javax.inject.Inject | ||
|
||
class AuthRepositoryImpl @Inject constructor( | ||
private val loginService: LoginService, | ||
private val authDataSource: AuthDataSource | ||
): AuthRepository { | ||
|
||
override suspend fun requestGoogleLogin(email: String) = handleResult { | ||
val request = GoogleLoginRequest(email = email) | ||
loginService.requestGoogleLogin(request) | ||
}.convert { | ||
it.toModel() | ||
} | ||
|
||
override suspend fun requestLogout(): DomainResult<Unit> = handleResult { | ||
loginService.requestLogout() | ||
} | ||
|
||
override suspend fun requestAccountDelete(): DomainResult<Unit> = handleResult { | ||
loginService.requestDeleteAccount() | ||
} | ||
|
||
override fun getAccessToken(): Flow<String?> = authDataSource.getAccessToken() | ||
|
||
override fun getRefreshToken(): Flow<String?> = authDataSource.getRefreshToken() | ||
|
||
override fun setAccessToken(accessToken: String): Flow<Unit> = authDataSource.setAccessToken(accessToken) | ||
|
||
override fun setRefreshToken(refreshToken: String): Flow<Unit> = authDataSource.setRefreshToken(refreshToken) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/model/src/main/AndroidManifest.xml → .../data/common/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> | ||
</manifest> |
25 changes: 25 additions & 0 deletions
25
core/data/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/ResultHandler.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.goalpanzi.mission_mate.core.data.common | ||
|
||
import com.goalpanzi.mission_mate.core.domain.common.DomainResult | ||
import retrofit2.HttpException | ||
import retrofit2.Response | ||
|
||
suspend fun <T : Any> handleResult(execute: suspend () -> Response<T>): DomainResult<T> { | ||
return try { | ||
val response = execute() | ||
if (response.isSuccessful) { | ||
val body = response.body() | ||
if (body != null) { | ||
DomainResult.Success(body) | ||
} else { | ||
DomainResult.Error(response.code(), "Response body is null") | ||
} | ||
} else { | ||
DomainResult.Error(response.code(), response.errorBody()?.string()) | ||
} | ||
} catch (e: HttpException) { | ||
DomainResult.Error(e.code(), e.message()) | ||
} catch (e: Throwable) { | ||
DomainResult.Exception(e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...a/common/src/main/java/com/goalpanzi/mission_mate/core/data/common/mapper/CommonMapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.goalpanzi.mission_mate.core.data.common.mapper | ||
|
||
import com.goalpanzi.mission_mate.core.domain.common.model.user.CharacterType | ||
import com.goalpanzi.mission_mate.core.domain.common.model.user.UserProfile | ||
import com.goalpanzi.mission_mate.core.network.model.response.CharacterTypeResponse | ||
import com.goalpanzi.mission_mate.core.network.model.response.ProfileResponse | ||
|
||
fun ProfileResponse.toModel() : UserProfile { | ||
return UserProfile( | ||
nickname = nickname, | ||
characterType = characterType.toModel() | ||
) | ||
} | ||
|
||
fun CharacterTypeResponse.toModel() : CharacterType { | ||
return try { | ||
CharacterType.valueOf(this.name) | ||
}catch (e: Exception){ | ||
CharacterType.RABBIT | ||
} | ||
} | ||
|
||
fun CharacterType.toResponse() : CharacterTypeResponse { | ||
return try { | ||
CharacterTypeResponse.valueOf(this.name) | ||
}catch (e: Exception){ | ||
CharacterTypeResponse.RABBIT | ||
} | ||
} | ||
|
17 changes: 17 additions & 0 deletions
17
.../data/common/src/test/java/com/goalpanzi/mission_mate/core/data/common/ExampleUnitTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.goalpanzi.mission_mate.core.data.common | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
|
||
plugins { | ||
alias(libs.plugins.android.library) | ||
alias(libs.plugins.jetbrains.kotlin.android) | ||
alias(libs.plugins.hilt.android) | ||
alias(libs.plugins.kotlin.ksp) | ||
} | ||
|
||
android { | ||
namespace = "com.goalpanzi.mission_mate.core.data.mission" | ||
compileSdk = 34 | ||
|
||
defaultConfig { | ||
minSdk = 26 | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
kotlin { | ||
compilerOptions { | ||
jvmTarget.set(JvmTarget.JVM_17) | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation(libs.bundles.test) | ||
implementation(libs.bundles.coroutines) | ||
implementation(libs.retrofit) | ||
|
||
ksp(libs.hilt.compiler) | ||
implementation(libs.hilt.android) | ||
|
||
implementation(project(":core:data:common")) | ||
implementation(project(":core:domain:common")) | ||
implementation(project(":core:domain:mission")) | ||
implementation(project(":core:network")) | ||
implementation(project(":core:datastore")) | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
core/data/src/main/AndroidManifest.xml → ...data/mission/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> | ||
</manifest> |
17 changes: 17 additions & 0 deletions
17
.../data/mission/src/main/java/com/goalpanzi/mission_mate/core/board/di/MissionDataModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.goalpanzi.mission_mate.core.board.di | ||
|
||
import com.goalpanzi.mission_mate.core.board.repository.MissionRepositoryImpl | ||
import com.goalpanzi.mission_mate.core.domain.mission.repository.MissionRepository | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
internal abstract class MissionDataModule { | ||
|
||
@Binds | ||
abstract fun bindMissionRepository(impl: MissionRepositoryImpl): MissionRepository | ||
|
||
} |
Oops, something went wrong.