From d4307818c79263639ec21dbfc459311ea8151218 Mon Sep 17 00:00:00 2001 From: jinukeu Date: Wed, 20 Dec 2023 20:06:39 +0900 Subject: [PATCH 01/13] =?UTF-8?q?feat/#65:=20login=20=EB=AA=A8=EB=93=88=20?= =?UTF-8?q?=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/login/.gitignore | 1 + data/login/build.gradle.kts | 13 ++++++ data/login/consumer-rules.pro | 0 data/login/proguard-rules.pro | 21 +++++++++ data/login/src/main/AndroidManifest.xml | 4 ++ .../login/datasource/LocalLoginDataSource.kt | 9 ++++ .../login/datasource/RemoteLoginDataSource.kt | 17 +++++++ .../suwiki/data/login/di/RepositoryModule.kt | 20 +++++++++ .../login/repository/LoginRepositoryImpl.kt | 32 +++++++++++++ data/user/build.gradle.kts | 1 + ...erDataSource.kt => LocalUserDataSource.kt} | 8 +++- .../datasource/LocalUserStorageDataSource.kt | 16 ------- .../user/datasource/RemoteUserDataSource.kt | 12 ----- .../user/repository/UserRepositoryImpl.kt | 35 ++++----------- domain/login/.gitignore | 1 + domain/login/build.gradle.kts | 13 ++++++ .../login/repository/LoginRepository.kt | 16 +++++++ .../domain/login}/usecase/FindIdUseCase.kt | 8 ++-- .../login}/usecase/FindPasswordUseCase.kt | 8 ++-- .../domain/login}/usecase/LoginUseCase.kt | 8 ++-- .../domain/user/repository/UserRepository.kt | 12 ----- local/login/.gitignore | 1 + local/login/build.gradle.kts | 20 +++++++++ local/login/consumer-rules.pro | 0 local/login/proguard-rules.pro | 21 +++++++++ local/login/src/main/AndroidManifest.xml | 4 ++ .../datasource/LocalLoginDataSourceImpl.kt | 18 ++++++++ .../local/login/di/LocalDataSourceModule.kt | 20 +++++++++ ...urceImpl.kt => LocalUserDataSourceImpl.kt} | 33 +++++++------- .../LocalUserProviderDataSourceImpl.kt | 26 ----------- .../local/user/di/LocalDataSourceModule.kt | 16 ++----- remote/login/.gitignore | 1 + remote/login/build.gradle.kts | 17 +++++++ remote/login/consumer-rules.pro | 0 remote/login/proguard-rules.pro | 21 +++++++++ remote/login/src/main/AndroidManifest.xml | 4 ++ .../com/suwiki/remote/login/api/LoginApi.kt | 35 +++++++++++++++ .../datasource/RemoteLoginDataSourceImpl.kt | 45 +++++++++++++++++++ .../com/suwiki/remote/login/di/ApiModule.kt | 21 +++++++++ .../remote/login/di/RemoteDataSourceModule.kt | 20 +++++++++ .../remote/login}/request/FindIdRequest.kt | 2 +- .../login}/request/FindPasswordRequest.kt | 2 +- .../remote/login}/request/LoginRequest.kt | 2 +- .../login/response/SuccessCheckResponse.kt | 8 ++++ .../remote/login/response/TokenResponse.kt | 16 +++++++ .../com/suwiki/remote/user/api/UserApi.kt | 22 --------- .../datasource/RemoteUserDataSourceImpl.kt | 33 -------------- settings.gradle.kts | 4 ++ 48 files changed, 476 insertions(+), 191 deletions(-) create mode 100644 data/login/.gitignore create mode 100644 data/login/build.gradle.kts create mode 100644 data/login/consumer-rules.pro create mode 100644 data/login/proguard-rules.pro create mode 100644 data/login/src/main/AndroidManifest.xml create mode 100644 data/login/src/main/java/com/suwiki/data/login/datasource/LocalLoginDataSource.kt create mode 100644 data/login/src/main/java/com/suwiki/data/login/datasource/RemoteLoginDataSource.kt create mode 100644 data/login/src/main/java/com/suwiki/data/login/di/RepositoryModule.kt create mode 100644 data/login/src/main/java/com/suwiki/data/login/repository/LoginRepositoryImpl.kt rename data/user/src/main/java/com/suwiki/data/user/datasource/{LocalUserProviderDataSource.kt => LocalUserDataSource.kt} (56%) delete mode 100644 data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserStorageDataSource.kt create mode 100644 domain/login/.gitignore create mode 100644 domain/login/build.gradle.kts create mode 100644 domain/login/src/main/java/com/suwiki/domain/login/repository/LoginRepository.kt rename domain/{user/src/main/java/com/suwiki/domain/user => login/src/main/java/com/suwiki/domain/login}/usecase/FindIdUseCase.kt (55%) rename domain/{user/src/main/java/com/suwiki/domain/user => login/src/main/java/com/suwiki/domain/login}/usecase/FindPasswordUseCase.kt (63%) rename domain/{user/src/main/java/com/suwiki/domain/user => login/src/main/java/com/suwiki/domain/login}/usecase/LoginUseCase.kt (64%) create mode 100644 local/login/.gitignore create mode 100644 local/login/build.gradle.kts create mode 100644 local/login/consumer-rules.pro create mode 100644 local/login/proguard-rules.pro create mode 100644 local/login/src/main/AndroidManifest.xml create mode 100644 local/login/src/main/java/com/suwiki/local/login/datasource/LocalLoginDataSourceImpl.kt create mode 100644 local/login/src/main/java/com/suwiki/local/login/di/LocalDataSourceModule.kt rename local/user/src/main/java/com/suwiki/local/user/datasource/{LocalUserStorageDataSourceImpl.kt => LocalUserDataSourceImpl.kt} (70%) delete mode 100644 local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserProviderDataSourceImpl.kt create mode 100644 remote/login/.gitignore create mode 100644 remote/login/build.gradle.kts create mode 100644 remote/login/consumer-rules.pro create mode 100644 remote/login/proguard-rules.pro create mode 100644 remote/login/src/main/AndroidManifest.xml create mode 100644 remote/login/src/main/java/com/suwiki/remote/login/api/LoginApi.kt create mode 100644 remote/login/src/main/java/com/suwiki/remote/login/datasource/RemoteLoginDataSourceImpl.kt create mode 100644 remote/login/src/main/java/com/suwiki/remote/login/di/ApiModule.kt create mode 100644 remote/login/src/main/java/com/suwiki/remote/login/di/RemoteDataSourceModule.kt rename remote/{user/src/main/java/com/suwiki/remote/user => login/src/main/java/com/suwiki/remote/login}/request/FindIdRequest.kt (71%) rename remote/{user/src/main/java/com/suwiki/remote/user => login/src/main/java/com/suwiki/remote/login}/request/FindPasswordRequest.kt (77%) rename remote/{user/src/main/java/com/suwiki/remote/user => login/src/main/java/com/suwiki/remote/login}/request/LoginRequest.kt (76%) create mode 100644 remote/login/src/main/java/com/suwiki/remote/login/response/SuccessCheckResponse.kt create mode 100644 remote/login/src/main/java/com/suwiki/remote/login/response/TokenResponse.kt diff --git a/data/login/.gitignore b/data/login/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/data/login/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/data/login/build.gradle.kts b/data/login/build.gradle.kts new file mode 100644 index 000000000..aac137b04 --- /dev/null +++ b/data/login/build.gradle.kts @@ -0,0 +1,13 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + alias(libs.plugins.suwiki.android.data) +} + +android { + namespace = "com.suwiki.data.login" +} + +dependencies { + implementation(projects.core.security) + implementation(projects.domain.login) +} diff --git a/data/login/consumer-rules.pro b/data/login/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/data/login/proguard-rules.pro b/data/login/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/data/login/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/data/login/src/main/AndroidManifest.xml b/data/login/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8bdb7e14b --- /dev/null +++ b/data/login/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/data/login/src/main/java/com/suwiki/data/login/datasource/LocalLoginDataSource.kt b/data/login/src/main/java/com/suwiki/data/login/datasource/LocalLoginDataSource.kt new file mode 100644 index 000000000..c23128e98 --- /dev/null +++ b/data/login/src/main/java/com/suwiki/data/login/datasource/LocalLoginDataSource.kt @@ -0,0 +1,9 @@ +package com.suwiki.data.login.datasource + +import com.suwiki.core.model.user.Token + +interface LocalLoginDataSource { + suspend fun setToken( + token: Token + ) +} diff --git a/data/login/src/main/java/com/suwiki/data/login/datasource/RemoteLoginDataSource.kt b/data/login/src/main/java/com/suwiki/data/login/datasource/RemoteLoginDataSource.kt new file mode 100644 index 000000000..4fdb1fe8d --- /dev/null +++ b/data/login/src/main/java/com/suwiki/data/login/datasource/RemoteLoginDataSource.kt @@ -0,0 +1,17 @@ +package com.suwiki.data.login.datasource + +import com.suwiki.core.model.user.Token + +interface RemoteLoginDataSource { + suspend fun findId(email: String) + + suspend fun findPassword( + loginId: String, + email: String, + ) + + suspend fun login( + loginId: String, + password: String, + ): Token +} diff --git a/data/login/src/main/java/com/suwiki/data/login/di/RepositoryModule.kt b/data/login/src/main/java/com/suwiki/data/login/di/RepositoryModule.kt new file mode 100644 index 000000000..43423c999 --- /dev/null +++ b/data/login/src/main/java/com/suwiki/data/login/di/RepositoryModule.kt @@ -0,0 +1,20 @@ +package com.suwiki.data.login.di + +import com.suwiki.data.login.repository.LoginRepositoryImpl +import com.suwiki.domain.login.repository.LoginRepository +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class RepositoryModule { + + @Singleton + @Binds + abstract fun bindLoginRepository( + loginRepositoryImpl: LoginRepositoryImpl, + ): LoginRepository +} diff --git a/data/login/src/main/java/com/suwiki/data/login/repository/LoginRepositoryImpl.kt b/data/login/src/main/java/com/suwiki/data/login/repository/LoginRepositoryImpl.kt new file mode 100644 index 000000000..c47ddfbc0 --- /dev/null +++ b/data/login/src/main/java/com/suwiki/data/login/repository/LoginRepositoryImpl.kt @@ -0,0 +1,32 @@ +package com.suwiki.data.login.repository + +import com.suwiki.data.login.datasource.LocalLoginDataSource +import com.suwiki.data.login.datasource.RemoteLoginDataSource +import com.suwiki.domain.login.repository.LoginRepository +import javax.inject.Inject + +class LoginRepositoryImpl @Inject constructor( + private val remoteLoginDataSource: RemoteLoginDataSource, + private val localLoginDataSource: LocalLoginDataSource, +) : LoginRepository { + + override suspend fun findId(email: String) { + remoteLoginDataSource.findId(email = email) + } + + override suspend fun findPassword(loginId: String, email: String) { + remoteLoginDataSource.findPassword( + loginId = loginId, + email = email, + ) + } + + override suspend fun login(loginId: String, password: String) { + val token = remoteLoginDataSource.login( + loginId = loginId, + password = password, + ) + + localLoginDataSource.setToken(token) + } +} diff --git a/data/user/build.gradle.kts b/data/user/build.gradle.kts index 13aa5fb02..abf0c4854 100644 --- a/data/user/build.gradle.kts +++ b/data/user/build.gradle.kts @@ -8,5 +8,6 @@ android { } dependencies { + implementation(projects.core.security) implementation(projects.domain.user) } diff --git a/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserProviderDataSource.kt b/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserDataSource.kt similarity index 56% rename from data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserProviderDataSource.kt rename to data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserDataSource.kt index 46bba0dc6..81f0b14db 100644 --- a/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserProviderDataSource.kt +++ b/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserDataSource.kt @@ -3,6 +3,12 @@ package com.suwiki.data.user.datasource import com.suwiki.core.model.user.User import kotlinx.coroutines.flow.Flow -interface LocalUserProviderDataSource { +interface LocalUserDataSource { val user: Flow + + suspend fun setUserInfo( + user: User, + ) + + suspend fun clearUserInfo() } diff --git a/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserStorageDataSource.kt b/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserStorageDataSource.kt deleted file mode 100644 index de9abe3ea..000000000 --- a/data/user/src/main/java/com/suwiki/data/user/datasource/LocalUserStorageDataSource.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.suwiki.data.user.datasource - -import com.suwiki.core.model.user.Token -import com.suwiki.core.model.user.User - -interface LocalUserStorageDataSource { - suspend fun setUserInfo( - user: User, - ) - - suspend fun setToken( - token: Token, - ) - - suspend fun clearUserInfoAndToken() -} diff --git a/data/user/src/main/java/com/suwiki/data/user/datasource/RemoteUserDataSource.kt b/data/user/src/main/java/com/suwiki/data/user/datasource/RemoteUserDataSource.kt index 380bbb395..13b5743aa 100644 --- a/data/user/src/main/java/com/suwiki/data/user/datasource/RemoteUserDataSource.kt +++ b/data/user/src/main/java/com/suwiki/data/user/datasource/RemoteUserDataSource.kt @@ -1,26 +1,14 @@ package com.suwiki.data.user.datasource -import com.suwiki.core.model.user.Token import com.suwiki.core.model.user.User interface RemoteUserDataSource { - suspend fun findId(email: String) - - suspend fun findPassword( - loginId: String, - email: String, - ) suspend fun resetPassword( currentPassword: String, newPassword: String, ) - suspend fun login( - loginId: String, - password: String, - ): Token - suspend fun quit( id: String, password: String, diff --git a/data/user/src/main/java/com/suwiki/data/user/repository/UserRepositoryImpl.kt b/data/user/src/main/java/com/suwiki/data/user/repository/UserRepositoryImpl.kt index 252a1ba2c..8f51c78ee 100644 --- a/data/user/src/main/java/com/suwiki/data/user/repository/UserRepositoryImpl.kt +++ b/data/user/src/main/java/com/suwiki/data/user/repository/UserRepositoryImpl.kt @@ -1,8 +1,8 @@ package com.suwiki.data.user.repository import com.suwiki.core.model.user.User -import com.suwiki.data.user.datasource.LocalUserProviderDataSource -import com.suwiki.data.user.datasource.LocalUserStorageDataSource +import com.suwiki.core.security.SecurityPreferences +import com.suwiki.data.user.datasource.LocalUserDataSource import com.suwiki.data.user.datasource.RemoteUserDataSource import com.suwiki.domain.user.repository.UserRepository import kotlinx.coroutines.flow.Flow @@ -11,23 +11,13 @@ import kotlinx.coroutines.flow.flow import javax.inject.Inject class UserRepositoryImpl @Inject constructor( - private val localUserProviderDataSource: LocalUserProviderDataSource, - private val localUserStorageDataSource: LocalUserStorageDataSource, + private val localUserDataSource: LocalUserDataSource, private val remoteUserDataSource: RemoteUserDataSource, + private val securityPreferences: SecurityPreferences, ) : UserRepository { override suspend fun logout() { - localUserStorageDataSource.clearUserInfoAndToken() - } - - override suspend fun findId(email: String) { - remoteUserDataSource.findId(email = email) - } - - override suspend fun findPassword(loginId: String, email: String) { - remoteUserDataSource.findPassword( - loginId = loginId, - email = email, - ) + localUserDataSource.clearUserInfo() + securityPreferences.clearAll() } override suspend fun resetPassword(currentPassword: String, newPassword: String) { @@ -37,15 +27,6 @@ class UserRepositoryImpl @Inject constructor( ) } - override suspend fun login(loginId: String, password: String) { - val token = remoteUserDataSource.login( - loginId = loginId, - password = password, - ) - - localUserStorageDataSource.setToken(token) - } - override suspend fun quit(id: String, password: String) { remoteUserDataSource.quit( id = id, @@ -54,12 +35,12 @@ class UserRepositoryImpl @Inject constructor( } override suspend fun getUserInfo(): Flow = flow { - val localUserInfo = localUserProviderDataSource.user.first() + val localUserInfo = localUserDataSource.user.first() emit(localUserInfo) val remoteUserInfo = remoteUserDataSource.getUserInfo() emit(remoteUserInfo) - localUserStorageDataSource.setUserInfo(remoteUserInfo) + localUserDataSource.setUserInfo(remoteUserInfo) } } diff --git a/domain/login/.gitignore b/domain/login/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/domain/login/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/domain/login/build.gradle.kts b/domain/login/build.gradle.kts new file mode 100644 index 000000000..a401e2cb5 --- /dev/null +++ b/domain/login/build.gradle.kts @@ -0,0 +1,13 @@ +@file:Suppress("DSL_SCOPE_VIOLATION") // @file:을 붙인 이유 -> https://github.com/gradle/gradle/issues/20131 + +plugins { + alias(libs.plugins.suwiki.java.library) +} + +dependencies { + implementation(projects.core.model) + implementation(projects.core.common) + + implementation(libs.kotlinx.coroutines.core) + implementation(libs.hilt.core) +} diff --git a/domain/login/src/main/java/com/suwiki/domain/login/repository/LoginRepository.kt b/domain/login/src/main/java/com/suwiki/domain/login/repository/LoginRepository.kt new file mode 100644 index 000000000..f6a1450c2 --- /dev/null +++ b/domain/login/src/main/java/com/suwiki/domain/login/repository/LoginRepository.kt @@ -0,0 +1,16 @@ +package com.suwiki.domain.login.repository + +interface LoginRepository { + + suspend fun findId(email: String) + + suspend fun findPassword( + loginId: String, + email: String, + ) + + suspend fun login( + loginId: String, + password: String, + ) +} diff --git a/domain/user/src/main/java/com/suwiki/domain/user/usecase/FindIdUseCase.kt b/domain/login/src/main/java/com/suwiki/domain/login/usecase/FindIdUseCase.kt similarity index 55% rename from domain/user/src/main/java/com/suwiki/domain/user/usecase/FindIdUseCase.kt rename to domain/login/src/main/java/com/suwiki/domain/login/usecase/FindIdUseCase.kt index f2213aaa6..5ad7d571d 100644 --- a/domain/user/src/main/java/com/suwiki/domain/user/usecase/FindIdUseCase.kt +++ b/domain/login/src/main/java/com/suwiki/domain/login/usecase/FindIdUseCase.kt @@ -1,13 +1,13 @@ -package com.suwiki.domain.user.usecase +package com.suwiki.domain.login.usecase import com.suwiki.core.common.runCatchingIgnoreCancelled -import com.suwiki.domain.user.repository.UserRepository +import com.suwiki.domain.login.repository.LoginRepository import javax.inject.Inject class FindIdUseCase @Inject constructor( - private val userRepository: UserRepository, + private val loginRepository: LoginRepository, ) { suspend operator fun invoke(email: String): Result = runCatchingIgnoreCancelled { - userRepository.findId(email) + loginRepository.findId(email) } } diff --git a/domain/user/src/main/java/com/suwiki/domain/user/usecase/FindPasswordUseCase.kt b/domain/login/src/main/java/com/suwiki/domain/login/usecase/FindPasswordUseCase.kt similarity index 63% rename from domain/user/src/main/java/com/suwiki/domain/user/usecase/FindPasswordUseCase.kt rename to domain/login/src/main/java/com/suwiki/domain/login/usecase/FindPasswordUseCase.kt index 8ab222605..035bdc92d 100644 --- a/domain/user/src/main/java/com/suwiki/domain/user/usecase/FindPasswordUseCase.kt +++ b/domain/login/src/main/java/com/suwiki/domain/login/usecase/FindPasswordUseCase.kt @@ -1,17 +1,17 @@ -package com.suwiki.domain.user.usecase +package com.suwiki.domain.login.usecase import com.suwiki.core.common.runCatchingIgnoreCancelled -import com.suwiki.domain.user.repository.UserRepository +import com.suwiki.domain.login.repository.LoginRepository import javax.inject.Inject class FindPasswordUseCase @Inject constructor( - private val userRepository: UserRepository, + private val loginRepository: LoginRepository, ) { suspend operator fun invoke( loginId: String, email: String, ): Result = runCatchingIgnoreCancelled { - userRepository.findPassword( + loginRepository.findPassword( loginId = loginId, email = email, ) diff --git a/domain/user/src/main/java/com/suwiki/domain/user/usecase/LoginUseCase.kt b/domain/login/src/main/java/com/suwiki/domain/login/usecase/LoginUseCase.kt similarity index 64% rename from domain/user/src/main/java/com/suwiki/domain/user/usecase/LoginUseCase.kt rename to domain/login/src/main/java/com/suwiki/domain/login/usecase/LoginUseCase.kt index f48863080..cf85139ed 100644 --- a/domain/user/src/main/java/com/suwiki/domain/user/usecase/LoginUseCase.kt +++ b/domain/login/src/main/java/com/suwiki/domain/login/usecase/LoginUseCase.kt @@ -1,17 +1,17 @@ -package com.suwiki.domain.user.usecase +package com.suwiki.domain.login.usecase import com.suwiki.core.common.runCatchingIgnoreCancelled -import com.suwiki.domain.user.repository.UserRepository +import com.suwiki.domain.login.repository.LoginRepository import javax.inject.Inject class LoginUseCase @Inject constructor( - private val userRepository: UserRepository, + private val loginRepository: LoginRepository, ) { suspend operator fun invoke( loginId: String, password: String, ): Result = runCatchingIgnoreCancelled { - userRepository.login( + loginRepository.login( loginId = loginId, password = password, ) diff --git a/domain/user/src/main/java/com/suwiki/domain/user/repository/UserRepository.kt b/domain/user/src/main/java/com/suwiki/domain/user/repository/UserRepository.kt index fd8113967..2e7b4769e 100644 --- a/domain/user/src/main/java/com/suwiki/domain/user/repository/UserRepository.kt +++ b/domain/user/src/main/java/com/suwiki/domain/user/repository/UserRepository.kt @@ -7,23 +7,11 @@ interface UserRepository { suspend fun logout() - suspend fun findId(email: String) - - suspend fun findPassword( - loginId: String, - email: String, - ) - suspend fun resetPassword( currentPassword: String, newPassword: String, ) - suspend fun login( - loginId: String, - password: String, - ) - suspend fun quit( id: String, password: String, diff --git a/local/login/.gitignore b/local/login/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/local/login/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/local/login/build.gradle.kts b/local/login/build.gradle.kts new file mode 100644 index 000000000..02b7e06a9 --- /dev/null +++ b/local/login/build.gradle.kts @@ -0,0 +1,20 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + alias(libs.plugins.suwiki.android.library) + alias(libs.plugins.suwiki.android.hilt) +} + +android { + namespace = "com.suwiki.local.login" +} + +dependencies { + implementation(projects.core.model) + implementation(projects.data.login) + implementation(projects.core.security) + + implementation(libs.bundles.coroutine) + + testImplementation(libs.junit4) + androidTestImplementation(libs.junit) +} diff --git a/local/login/consumer-rules.pro b/local/login/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/local/login/proguard-rules.pro b/local/login/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/local/login/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/local/login/src/main/AndroidManifest.xml b/local/login/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8bdb7e14b --- /dev/null +++ b/local/login/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/local/login/src/main/java/com/suwiki/local/login/datasource/LocalLoginDataSourceImpl.kt b/local/login/src/main/java/com/suwiki/local/login/datasource/LocalLoginDataSourceImpl.kt new file mode 100644 index 000000000..a575aefaa --- /dev/null +++ b/local/login/src/main/java/com/suwiki/local/login/datasource/LocalLoginDataSourceImpl.kt @@ -0,0 +1,18 @@ +package com.suwiki.local.login.datasource + +import com.suwiki.core.model.user.Token +import com.suwiki.core.security.SecurityPreferences +import com.suwiki.data.login.datasource.LocalLoginDataSource +import javax.inject.Inject + +class LocalLoginDataSourceImpl @Inject constructor( + private val securityPreferences: SecurityPreferences, +) : LocalLoginDataSource { + + override suspend fun setToken(token: Token) { + token.run { + securityPreferences.setAccessToken(accessToken) + securityPreferences.setRefreshToken(refreshToken) + } + } +} diff --git a/local/login/src/main/java/com/suwiki/local/login/di/LocalDataSourceModule.kt b/local/login/src/main/java/com/suwiki/local/login/di/LocalDataSourceModule.kt new file mode 100644 index 000000000..9287a674f --- /dev/null +++ b/local/login/src/main/java/com/suwiki/local/login/di/LocalDataSourceModule.kt @@ -0,0 +1,20 @@ +package com.suwiki.local.login.di + +import com.suwiki.data.login.datasource.LocalLoginDataSource +import com.suwiki.local.login.datasource.LocalLoginDataSourceImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class LocalDataSourceModule { + + @Singleton + @Binds + abstract fun bindLocalLoginDataSource( + localLoginDataSourceImpl: LocalLoginDataSourceImpl, + ): LocalLoginDataSource +} diff --git a/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserStorageDataSourceImpl.kt b/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserDataSourceImpl.kt similarity index 70% rename from local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserStorageDataSourceImpl.kt rename to local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserDataSourceImpl.kt index 5937e9e79..abed5497b 100644 --- a/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserStorageDataSourceImpl.kt +++ b/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserDataSourceImpl.kt @@ -8,16 +8,27 @@ import com.suwiki.core.model.user.DEFAULT_USER_POINT import com.suwiki.core.model.user.DEFAULT_USER_VIEW_EXAM import com.suwiki.core.model.user.DEFAULT_USER_WRITTEN_EVALUATION import com.suwiki.core.model.user.DEFAULT_USER_WRITTEN_EXAM -import com.suwiki.core.model.user.Token import com.suwiki.core.model.user.User -import com.suwiki.core.security.SecurityPreferences -import com.suwiki.data.user.datasource.LocalUserStorageDataSource +import com.suwiki.data.user.datasource.LocalUserDataSource +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map import javax.inject.Inject -class LocalUserStorageDataSourceImpl @Inject constructor( +class LocalUserDataSourceImpl @Inject constructor( private val dataStore: DataStore, - private val securityPreferences: SecurityPreferences, -) : LocalUserStorageDataSource { +) : LocalUserDataSource { + + override val user: Flow + get() = dataStore.data.map { + User( + userId = it.userId, + email = it.email, + point = it.point, + writtenEvaluation = it.writtenEvaluation, + writtenExam = it.writtenExam, + viewExam = it.viewExam, + ) + } override suspend fun setUserInfo(user: User) { user.run { @@ -35,15 +46,7 @@ class LocalUserStorageDataSourceImpl @Inject constructor( } } - override suspend fun setToken(token: Token) { - token.run { - securityPreferences.setAccessToken(accessToken) - securityPreferences.setRefreshToken(refreshToken) - } - } - - override suspend fun clearUserInfoAndToken() { - securityPreferences.clearAll() + override suspend fun clearUserInfo() { dataStore.updateData { userPref -> userPref .toBuilder() diff --git a/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserProviderDataSourceImpl.kt b/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserProviderDataSourceImpl.kt deleted file mode 100644 index b947ce00f..000000000 --- a/local/user/src/main/java/com/suwiki/local/user/datasource/LocalUserProviderDataSourceImpl.kt +++ /dev/null @@ -1,26 +0,0 @@ -package com.suwiki.local.user.datasource - -import androidx.datastore.core.DataStore -import com.suwiki.core.database.UserPreference -import com.suwiki.core.model.user.User -import com.suwiki.data.user.datasource.LocalUserProviderDataSource -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.map -import javax.inject.Inject - -class LocalUserProviderDataSourceImpl @Inject constructor( - private val dataStore: DataStore, -) : LocalUserProviderDataSource { - - override val user: Flow - get() = dataStore.data.map { - User( - userId = it.userId, - email = it.email, - point = it.point, - writtenEvaluation = it.writtenEvaluation, - writtenExam = it.writtenExam, - viewExam = it.viewExam, - ) - } -} diff --git a/local/user/src/main/java/com/suwiki/local/user/di/LocalDataSourceModule.kt b/local/user/src/main/java/com/suwiki/local/user/di/LocalDataSourceModule.kt index 50d35e87b..05d9daf07 100644 --- a/local/user/src/main/java/com/suwiki/local/user/di/LocalDataSourceModule.kt +++ b/local/user/src/main/java/com/suwiki/local/user/di/LocalDataSourceModule.kt @@ -1,9 +1,7 @@ package com.suwiki.local.user.di -import com.suwiki.data.user.datasource.LocalUserProviderDataSource -import com.suwiki.data.user.datasource.LocalUserStorageDataSource -import com.suwiki.local.user.datasource.LocalUserProviderDataSourceImpl -import com.suwiki.local.user.datasource.LocalUserStorageDataSourceImpl +import com.suwiki.data.user.datasource.LocalUserDataSource +import com.suwiki.local.user.datasource.LocalUserDataSourceImpl import dagger.Binds import dagger.Module import dagger.hilt.InstallIn @@ -17,12 +15,6 @@ abstract class LocalDataSourceModule { @Singleton @Binds abstract fun bindLocalUserProviderDataSource( - localUserProviderDataSourceImpl: LocalUserProviderDataSourceImpl, - ): LocalUserProviderDataSource - - @Singleton - @Binds - abstract fun bindLocalUserStorageDataSource( - localUserStorageDataSourceImpl: LocalUserStorageDataSourceImpl, - ): LocalUserStorageDataSource + localUserProviderDataSourceImpl: LocalUserDataSourceImpl, + ): LocalUserDataSource } diff --git a/remote/login/.gitignore b/remote/login/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/remote/login/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/remote/login/build.gradle.kts b/remote/login/build.gradle.kts new file mode 100644 index 000000000..162ff78ca --- /dev/null +++ b/remote/login/build.gradle.kts @@ -0,0 +1,17 @@ +@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed +plugins { + alias(libs.plugins.suwiki.android.remote) + alias(libs.plugins.kotlin.serialization) +} + +android { + namespace = "com.suwiki.remote.login" +} + +dependencies { + implementation(projects.data.login) + + implementation(libs.retrofit.core) + implementation(libs.kotlinx.serialization.json) + implementation(libs.kotlinx.datetime) +} diff --git a/remote/login/consumer-rules.pro b/remote/login/consumer-rules.pro new file mode 100644 index 000000000..e69de29bb diff --git a/remote/login/proguard-rules.pro b/remote/login/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/remote/login/proguard-rules.pro @@ -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 \ No newline at end of file diff --git a/remote/login/src/main/AndroidManifest.xml b/remote/login/src/main/AndroidManifest.xml new file mode 100644 index 000000000..8bdb7e14b --- /dev/null +++ b/remote/login/src/main/AndroidManifest.xml @@ -0,0 +1,4 @@ + + + + diff --git a/remote/login/src/main/java/com/suwiki/remote/login/api/LoginApi.kt b/remote/login/src/main/java/com/suwiki/remote/login/api/LoginApi.kt new file mode 100644 index 000000000..08449c9ee --- /dev/null +++ b/remote/login/src/main/java/com/suwiki/remote/login/api/LoginApi.kt @@ -0,0 +1,35 @@ +package com.suwiki.remote.login.api + +import com.suwiki.core.network.retrofit.ApiResult +import com.suwiki.remote.login.request.FindIdRequest +import com.suwiki.remote.login.request.FindPasswordRequest +import com.suwiki.remote.login.request.LoginRequest +import com.suwiki.remote.login.response.SuccessCheckResponse +import com.suwiki.remote.login.response.TokenResponse +import retrofit2.http.Body +import retrofit2.http.POST + +// TODO : v2 api로 업그레이드 필요. +interface LoginApi { + companion object { + const val USER = "/user" + } + + // 아이디 찾기 API + @POST("$USER/find-id") + suspend fun findId( + @Body findIdRequest: FindIdRequest, + ): ApiResult + + // 비밀번호 찾기(임시 비밀번호 전송) API + @POST("$USER/find-pw") + suspend fun findPassword( + @Body findPasswordRequest: FindPasswordRequest, + ): ApiResult + + // 로그인 요청 API + @POST("$USER/login") + suspend fun login( + @Body loginRequest: LoginRequest, + ): ApiResult +} diff --git a/remote/login/src/main/java/com/suwiki/remote/login/datasource/RemoteLoginDataSourceImpl.kt b/remote/login/src/main/java/com/suwiki/remote/login/datasource/RemoteLoginDataSourceImpl.kt new file mode 100644 index 000000000..acd0aed31 --- /dev/null +++ b/remote/login/src/main/java/com/suwiki/remote/login/datasource/RemoteLoginDataSourceImpl.kt @@ -0,0 +1,45 @@ +package com.suwiki.remote.login.datasource + +import com.suwiki.core.model.exception.RequestFailException +import com.suwiki.core.model.user.Token +import com.suwiki.data.login.datasource.RemoteLoginDataSource +import com.suwiki.remote.login.api.LoginApi +import com.suwiki.remote.login.request.FindIdRequest +import com.suwiki.remote.login.request.FindPasswordRequest +import com.suwiki.remote.login.request.LoginRequest +import com.suwiki.remote.login.response.toModel +import javax.inject.Inject + +class RemoteLoginDataSourceImpl @Inject constructor( + private val loginApi: LoginApi, +) : RemoteLoginDataSource { + + override suspend fun findId(email: String) { + loginApi + .findId(FindIdRequest(email)) + .getOrThrow() + .run { + if (!success) throw RequestFailException() + } + } + + override suspend fun findPassword(loginId: String, email: String) { + loginApi + .findPassword( + FindPasswordRequest(loginId, email), + ) + .getOrThrow() + .run { + if (!success) throw RequestFailException() + } + } + + override suspend fun login(loginId: String, password: String): Token { + return loginApi.login( + LoginRequest( + loginId = loginId, + password = password, + ), + ).getOrThrow().toModel() + } +} diff --git a/remote/login/src/main/java/com/suwiki/remote/login/di/ApiModule.kt b/remote/login/src/main/java/com/suwiki/remote/login/di/ApiModule.kt new file mode 100644 index 000000000..49c99f7bb --- /dev/null +++ b/remote/login/src/main/java/com/suwiki/remote/login/di/ApiModule.kt @@ -0,0 +1,21 @@ +package com.suwiki.remote.login.di + +import com.suwiki.core.network.di.AuthRetrofit +import com.suwiki.remote.login.api.LoginApi +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import retrofit2.Retrofit +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +object ApiModule { + + @Singleton + @Provides + fun provideUserApi(@AuthRetrofit retrofit: Retrofit): LoginApi { + return retrofit.create(LoginApi::class.java) + } +} diff --git a/remote/login/src/main/java/com/suwiki/remote/login/di/RemoteDataSourceModule.kt b/remote/login/src/main/java/com/suwiki/remote/login/di/RemoteDataSourceModule.kt new file mode 100644 index 000000000..ebe86dbd6 --- /dev/null +++ b/remote/login/src/main/java/com/suwiki/remote/login/di/RemoteDataSourceModule.kt @@ -0,0 +1,20 @@ +package com.suwiki.remote.login.di + +import com.suwiki.data.login.datasource.RemoteLoginDataSource +import com.suwiki.remote.login.datasource.RemoteLoginDataSourceImpl +import dagger.Binds +import dagger.Module +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +abstract class RemoteDataSourceModule { + + @Singleton + @Binds + abstract fun bindRemoteLoginDatasource( + remoteLoginDataSourceImpl: RemoteLoginDataSourceImpl, + ): RemoteLoginDataSource +} diff --git a/remote/user/src/main/java/com/suwiki/remote/user/request/FindIdRequest.kt b/remote/login/src/main/java/com/suwiki/remote/login/request/FindIdRequest.kt similarity index 71% rename from remote/user/src/main/java/com/suwiki/remote/user/request/FindIdRequest.kt rename to remote/login/src/main/java/com/suwiki/remote/login/request/FindIdRequest.kt index 93fe7b793..bc5366068 100644 --- a/remote/user/src/main/java/com/suwiki/remote/user/request/FindIdRequest.kt +++ b/remote/login/src/main/java/com/suwiki/remote/login/request/FindIdRequest.kt @@ -1,4 +1,4 @@ -package com.suwiki.remote.user.request +package com.suwiki.remote.login.request import kotlinx.serialization.Serializable diff --git a/remote/user/src/main/java/com/suwiki/remote/user/request/FindPasswordRequest.kt b/remote/login/src/main/java/com/suwiki/remote/login/request/FindPasswordRequest.kt similarity index 77% rename from remote/user/src/main/java/com/suwiki/remote/user/request/FindPasswordRequest.kt rename to remote/login/src/main/java/com/suwiki/remote/login/request/FindPasswordRequest.kt index 49f6bcf4f..47a0c4c2e 100644 --- a/remote/user/src/main/java/com/suwiki/remote/user/request/FindPasswordRequest.kt +++ b/remote/login/src/main/java/com/suwiki/remote/login/request/FindPasswordRequest.kt @@ -1,4 +1,4 @@ -package com.suwiki.remote.user.request +package com.suwiki.remote.login.request import kotlinx.serialization.Serializable diff --git a/remote/user/src/main/java/com/suwiki/remote/user/request/LoginRequest.kt b/remote/login/src/main/java/com/suwiki/remote/login/request/LoginRequest.kt similarity index 76% rename from remote/user/src/main/java/com/suwiki/remote/user/request/LoginRequest.kt rename to remote/login/src/main/java/com/suwiki/remote/login/request/LoginRequest.kt index b1e0260af..9b4a84b36 100644 --- a/remote/user/src/main/java/com/suwiki/remote/user/request/LoginRequest.kt +++ b/remote/login/src/main/java/com/suwiki/remote/login/request/LoginRequest.kt @@ -1,4 +1,4 @@ -package com.suwiki.remote.user.request +package com.suwiki.remote.login.request import kotlinx.serialization.Serializable diff --git a/remote/login/src/main/java/com/suwiki/remote/login/response/SuccessCheckResponse.kt b/remote/login/src/main/java/com/suwiki/remote/login/response/SuccessCheckResponse.kt new file mode 100644 index 000000000..b7bc7f9f2 --- /dev/null +++ b/remote/login/src/main/java/com/suwiki/remote/login/response/SuccessCheckResponse.kt @@ -0,0 +1,8 @@ +package com.suwiki.remote.login.response + +import kotlinx.serialization.Serializable + +@Serializable +data class SuccessCheckResponse( + val success: Boolean, +) diff --git a/remote/login/src/main/java/com/suwiki/remote/login/response/TokenResponse.kt b/remote/login/src/main/java/com/suwiki/remote/login/response/TokenResponse.kt new file mode 100644 index 000000000..c1f9c1900 --- /dev/null +++ b/remote/login/src/main/java/com/suwiki/remote/login/response/TokenResponse.kt @@ -0,0 +1,16 @@ +package com.suwiki.remote.login.response + +import com.suwiki.core.model.user.Token +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class TokenResponse( + @SerialName("AccessToken") val accessToken: String, + @SerialName("RefreshToken") val refreshToken: String, +) + +internal fun TokenResponse.toModel() = Token( + accessToken = accessToken, + refreshToken = refreshToken, +) diff --git a/remote/user/src/main/java/com/suwiki/remote/user/api/UserApi.kt b/remote/user/src/main/java/com/suwiki/remote/user/api/UserApi.kt index 471b09faf..acbcb67f8 100644 --- a/remote/user/src/main/java/com/suwiki/remote/user/api/UserApi.kt +++ b/remote/user/src/main/java/com/suwiki/remote/user/api/UserApi.kt @@ -1,13 +1,9 @@ package com.suwiki.remote.user.api import com.suwiki.core.network.retrofit.ApiResult -import com.suwiki.remote.user.request.FindIdRequest -import com.suwiki.remote.user.request.FindPasswordRequest -import com.suwiki.remote.user.request.LoginRequest import com.suwiki.remote.user.request.QuitRequest import com.suwiki.remote.user.request.ResetPasswordRequest import com.suwiki.remote.user.response.SuccessCheckResponse -import com.suwiki.remote.user.response.TokenResponse import com.suwiki.remote.user.response.UserResponse import retrofit2.http.Body import retrofit2.http.GET @@ -19,24 +15,6 @@ interface UserApi { const val USER = "/user" } - // 아이디 찾기 API - @POST("$USER/find-id") - suspend fun findId( - @Body findIdRequest: FindIdRequest, - ): ApiResult - - // 비밀번호 찾기(임시 비밀번호 전송) API - @POST("$USER/find-pw") - suspend fun findPassword( - @Body findPasswordRequest: FindPasswordRequest, - ): ApiResult - - // 로그인 요청 API - @POST("$USER/login") - suspend fun login( - @Body loginRequest: LoginRequest, - ): ApiResult - // 비밀번호 재설정 API @POST("$USER/reset-pw") suspend fun resetPassword( diff --git a/remote/user/src/main/java/com/suwiki/remote/user/datasource/RemoteUserDataSourceImpl.kt b/remote/user/src/main/java/com/suwiki/remote/user/datasource/RemoteUserDataSourceImpl.kt index f6b69797f..3022ac844 100644 --- a/remote/user/src/main/java/com/suwiki/remote/user/datasource/RemoteUserDataSourceImpl.kt +++ b/remote/user/src/main/java/com/suwiki/remote/user/datasource/RemoteUserDataSourceImpl.kt @@ -1,13 +1,9 @@ package com.suwiki.remote.user.datasource import com.suwiki.core.model.exception.RequestFailException -import com.suwiki.core.model.user.Token import com.suwiki.core.model.user.User import com.suwiki.data.user.datasource.RemoteUserDataSource import com.suwiki.remote.user.api.UserApi -import com.suwiki.remote.user.request.FindIdRequest -import com.suwiki.remote.user.request.FindPasswordRequest -import com.suwiki.remote.user.request.LoginRequest import com.suwiki.remote.user.request.QuitRequest import com.suwiki.remote.user.request.ResetPasswordRequest import com.suwiki.remote.user.response.toModel @@ -17,26 +13,6 @@ class RemoteUserDataSourceImpl @Inject constructor( private val userApi: UserApi, ) : RemoteUserDataSource { - override suspend fun findId(email: String) { - userApi - .findId(FindIdRequest(email)) - .getOrThrow() - .run { - if (!success) throw RequestFailException() - } - } - - override suspend fun findPassword(loginId: String, email: String) { - userApi - .findPassword( - FindPasswordRequest(loginId, email), - ) - .getOrThrow() - .run { - if (!success) throw RequestFailException() - } - } - override suspend fun resetPassword( currentPassword: String, newPassword: String, @@ -51,15 +27,6 @@ class RemoteUserDataSourceImpl @Inject constructor( } } - override suspend fun login(loginId: String, password: String): Token { - return userApi.login( - LoginRequest( - loginId = loginId, - password = password, - ), - ).getOrThrow().toModel() - } - override suspend fun quit(id: String, password: String) { userApi.quit( QuitRequest( diff --git a/settings.gradle.kts b/settings.gradle.kts index 98936914e..247192239 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -61,3 +61,7 @@ include(":domain:lectureevaluation:my") include(":domain:lectureevaluation:editor") include(":domain:timetable") include(":domain:notice") +include(":remote:login") +include(":domain:login") +include(":data:login") +include(":local:login") From ee424defb887018d529917e9e12123c6a98d2ea8 Mon Sep 17 00:00:00 2001 From: jinukeu Date: Wed, 20 Dec 2023 22:17:46 +0900 Subject: [PATCH 02/13] =?UTF-8?q?feat/#65:=20feature=20=EB=AA=A8=EB=93=88?= =?UTF-8?q?=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app-compose/build.gradle.kts | 41 +----------- .../java/FeatureComposeConventionPlugin.kt | 6 ++ .../src/main/res/values/themes.xml | 5 ++ .../lectureevaluation/editor}/.gitignore | 0 .../lectureevaluation/editor/build.gradle.kts | 12 ++++ .../editor}/consumer-rules.pro | 0 .../editor}/proguard-rules.pro | 0 .../editor/ExampleInstrumentedTest.kt | 24 +++++++ .../editor/src/main/AndroidManifest.xml | 4 ++ .../editor/ExampleUnitTest.kt | 17 +++++ feature/lectureevaluation/my/.gitignore | 1 + feature/lectureevaluation/my/build.gradle.kts | 12 ++++ .../lectureevaluation/my/consumer-rules.pro | 0 .../lectureevaluation/my/proguard-rules.pro | 21 ++++++ .../my/ExampleInstrumentedTest.kt | 24 +++++++ .../my/src/main/AndroidManifest.xml | 4 ++ .../lectureevaluation/my/ExampleUnitTest.kt | 17 +++++ .../viewerreporter/.gitignore | 1 + .../viewerreporter/build.gradle.kts | 12 ++++ .../viewerreporter/consumer-rules.pro | 0 .../viewerreporter/proguard-rules.pro | 21 ++++++ .../viewerreporter/ExampleInstrumentedTest.kt | 27 ++++++++ .../src/main/AndroidManifest.xml | 4 ++ .../viewerreporter/ExampleUnitTest.kt | 17 +++++ feature/login/.gitignore | 1 + feature/login/build.gradle.kts | 12 ++++ feature/login/consumer-rules.pro | 0 feature/login/proguard-rules.pro | 21 ++++++ .../feature/login}/ExampleInstrumentedTest.kt | 20 +++--- feature/login/src/main/AndroidManifest.xml | 4 ++ .../suwiki/feature/login}/ExampleUnitTest.kt | 13 ++-- feature/myinfo/.gitignore | 1 + feature/myinfo/build.gradle.kts | 12 ++++ feature/myinfo/consumer-rules.pro | 0 feature/myinfo/proguard-rules.pro | 21 ++++++ .../feature/myinfo/ExampleInstrumentedTest.kt | 24 +++++++ feature/myinfo/src/main/AndroidManifest.xml | 4 ++ .../suwiki/feature/myinfo/ExampleUnitTest.kt | 17 +++++ feature/navigator/.gitignore | 1 + feature/navigator/build.gradle.kts | 21 ++++++ feature/navigator/consumer-rules.pro | 0 feature/navigator/proguard-rules.pro | 21 ++++++ .../navigator/ExampleInstrumentedTest.kt | 24 +++++++ .../navigator/src/main/AndroidManifest.xml | 19 ++++++ .../suwiki/feature/navigator/MainActivity.kt | 40 ++++++++++++ .../navigator/src/main/res/values/strings.xml | 4 ++ .../feature/navigator/ExampleUnitTest.kt | 17 +++++ feature/notice/.gitignore | 1 + feature/notice/build.gradle.kts | 12 ++++ feature/notice/consumer-rules.pro | 0 feature/notice/proguard-rules.pro | 21 ++++++ .../feature/notice/ExampleInstrumentedTest.kt | 24 +++++++ feature/notice/src/main/AndroidManifest.xml | 4 ++ .../suwiki/feature/notice/ExampleUnitTest.kt | 17 +++++ feature/openmajor/.gitignore | 1 + feature/openmajor/build.gradle.kts | 12 ++++ feature/openmajor/consumer-rules.pro | 0 feature/openmajor/proguard-rules.pro | 21 ++++++ .../openmajor/ExampleInstrumentedTest.kt | 24 +++++++ .../openmajor/src/main/AndroidManifest.xml | 4 ++ .../feature/openmajor/ExampleUnitTest.kt | 17 +++++ feature/signup/.gitignore | 1 + feature/signup/build.gradle.kts | 12 ++++ feature/signup/consumer-rules.pro | 0 feature/signup/proguard-rules.pro | 21 ++++++ .../feature/signup/ExampleInstrumentedTest.kt | 24 +++++++ feature/signup/src/main/AndroidManifest.xml | 4 ++ .../suwiki/feature/signup/ExampleUnitTest.kt | 17 +++++ feature/timetable/.gitignore | 1 + feature/timetable/build.gradle.kts | 12 ++++ feature/timetable/consumer-rules.pro | 0 feature/timetable/proguard-rules.pro | 21 ++++++ .../timetable/ExampleInstrumentedTest.kt | 24 +++++++ .../timetable/src/main/AndroidManifest.xml | 4 ++ .../feature/timetable/ExampleUnitTest.kt | 17 +++++ presentation/build.gradle.kts | 15 ----- presentation/src/main/AndroidManifest.xml | 19 ------ .../com/mangbaam/presentation/MainActivity.kt | 64 ------------------- .../common/CommonRecyclerViewState.kt | 34 ---------- .../presentation/extension/Activity.kt | 33 ---------- .../presentation/extension/Fragment.kt | 25 -------- .../mangbaam/presentation/ui/theme/Color.kt | 11 ---- .../mangbaam/presentation/ui/theme/Theme.kt | 60 ----------------- .../mangbaam/presentation/ui/theme/Type.kt | 18 ------ presentation/src/main/res/values/strings.xml | 3 - presentation/src/main/res/values/themes.xml | 5 -- settings.gradle.kts | 18 ++++-- 87 files changed, 842 insertions(+), 346 deletions(-) create mode 100644 core/designsystem/src/main/res/values/themes.xml rename {presentation => feature/lectureevaluation/editor}/.gitignore (100%) create mode 100644 feature/lectureevaluation/editor/build.gradle.kts rename {presentation => feature/lectureevaluation/editor}/consumer-rules.pro (100%) rename {presentation => feature/lectureevaluation/editor}/proguard-rules.pro (100%) create mode 100644 feature/lectureevaluation/editor/src/androidTest/java/com/suwiki/feature/lectureevaluation/editor/ExampleInstrumentedTest.kt create mode 100644 feature/lectureevaluation/editor/src/main/AndroidManifest.xml create mode 100644 feature/lectureevaluation/editor/src/test/java/com/suwiki/feature/lectureevaluation/editor/ExampleUnitTest.kt create mode 100644 feature/lectureevaluation/my/.gitignore create mode 100644 feature/lectureevaluation/my/build.gradle.kts create mode 100644 feature/lectureevaluation/my/consumer-rules.pro create mode 100644 feature/lectureevaluation/my/proguard-rules.pro create mode 100644 feature/lectureevaluation/my/src/androidTest/java/com/suwiki/feature/lectureevaluation/my/ExampleInstrumentedTest.kt create mode 100644 feature/lectureevaluation/my/src/main/AndroidManifest.xml create mode 100644 feature/lectureevaluation/my/src/test/java/com/suwiki/feature/lectureevaluation/my/ExampleUnitTest.kt create mode 100644 feature/lectureevaluation/viewerreporter/.gitignore create mode 100644 feature/lectureevaluation/viewerreporter/build.gradle.kts create mode 100644 feature/lectureevaluation/viewerreporter/consumer-rules.pro create mode 100644 feature/lectureevaluation/viewerreporter/proguard-rules.pro create mode 100644 feature/lectureevaluation/viewerreporter/src/androidTest/java/com/suwiki/feature/lectureevaluation/viewerreporter/ExampleInstrumentedTest.kt create mode 100644 feature/lectureevaluation/viewerreporter/src/main/AndroidManifest.xml create mode 100644 feature/lectureevaluation/viewerreporter/src/test/java/com/suwiki/feature/lectureevaluation/viewerreporter/ExampleUnitTest.kt create mode 100644 feature/login/.gitignore create mode 100644 feature/login/build.gradle.kts create mode 100644 feature/login/consumer-rules.pro create mode 100644 feature/login/proguard-rules.pro rename {presentation/src/androidTest/java/com/mangbaam/presentation => feature/login/src/androidTest/java/com/suwiki/feature/login}/ExampleInstrumentedTest.kt (54%) create mode 100644 feature/login/src/main/AndroidManifest.xml rename {presentation/src/test/java/com/mangbaam/presentation => feature/login/src/test/java/com/suwiki/feature/login}/ExampleUnitTest.kt (58%) create mode 100644 feature/myinfo/.gitignore create mode 100644 feature/myinfo/build.gradle.kts create mode 100644 feature/myinfo/consumer-rules.pro create mode 100644 feature/myinfo/proguard-rules.pro create mode 100644 feature/myinfo/src/androidTest/java/com/suwiki/feature/myinfo/ExampleInstrumentedTest.kt create mode 100644 feature/myinfo/src/main/AndroidManifest.xml create mode 100644 feature/myinfo/src/test/java/com/suwiki/feature/myinfo/ExampleUnitTest.kt create mode 100644 feature/navigator/.gitignore create mode 100644 feature/navigator/build.gradle.kts create mode 100644 feature/navigator/consumer-rules.pro create mode 100644 feature/navigator/proguard-rules.pro create mode 100644 feature/navigator/src/androidTest/java/com/suwiki/feature/navigator/ExampleInstrumentedTest.kt create mode 100644 feature/navigator/src/main/AndroidManifest.xml create mode 100644 feature/navigator/src/main/java/com/suwiki/feature/navigator/MainActivity.kt create mode 100644 feature/navigator/src/main/res/values/strings.xml create mode 100644 feature/navigator/src/test/java/com/suwiki/feature/navigator/ExampleUnitTest.kt create mode 100644 feature/notice/.gitignore create mode 100644 feature/notice/build.gradle.kts create mode 100644 feature/notice/consumer-rules.pro create mode 100644 feature/notice/proguard-rules.pro create mode 100644 feature/notice/src/androidTest/java/com/suwiki/feature/notice/ExampleInstrumentedTest.kt create mode 100644 feature/notice/src/main/AndroidManifest.xml create mode 100644 feature/notice/src/test/java/com/suwiki/feature/notice/ExampleUnitTest.kt create mode 100644 feature/openmajor/.gitignore create mode 100644 feature/openmajor/build.gradle.kts create mode 100644 feature/openmajor/consumer-rules.pro create mode 100644 feature/openmajor/proguard-rules.pro create mode 100644 feature/openmajor/src/androidTest/java/com/suwiki/feature/openmajor/ExampleInstrumentedTest.kt create mode 100644 feature/openmajor/src/main/AndroidManifest.xml create mode 100644 feature/openmajor/src/test/java/com/suwiki/feature/openmajor/ExampleUnitTest.kt create mode 100644 feature/signup/.gitignore create mode 100644 feature/signup/build.gradle.kts create mode 100644 feature/signup/consumer-rules.pro create mode 100644 feature/signup/proguard-rules.pro create mode 100644 feature/signup/src/androidTest/java/com/suwiki/feature/signup/ExampleInstrumentedTest.kt create mode 100644 feature/signup/src/main/AndroidManifest.xml create mode 100644 feature/signup/src/test/java/com/suwiki/feature/signup/ExampleUnitTest.kt create mode 100644 feature/timetable/.gitignore create mode 100644 feature/timetable/build.gradle.kts create mode 100644 feature/timetable/consumer-rules.pro create mode 100644 feature/timetable/proguard-rules.pro create mode 100644 feature/timetable/src/androidTest/java/com/suwiki/feature/timetable/ExampleInstrumentedTest.kt create mode 100644 feature/timetable/src/main/AndroidManifest.xml create mode 100644 feature/timetable/src/test/java/com/suwiki/feature/timetable/ExampleUnitTest.kt delete mode 100644 presentation/build.gradle.kts delete mode 100644 presentation/src/main/AndroidManifest.xml delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/MainActivity.kt delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/common/CommonRecyclerViewState.kt delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/extension/Activity.kt delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/extension/Fragment.kt delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/ui/theme/Color.kt delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/ui/theme/Theme.kt delete mode 100644 presentation/src/main/java/com/mangbaam/presentation/ui/theme/Type.kt delete mode 100644 presentation/src/main/res/values/strings.xml delete mode 100644 presentation/src/main/res/values/themes.xml diff --git a/app-compose/build.gradle.kts b/app-compose/build.gradle.kts index fa34d3bc3..66bbc850d 100644 --- a/app-compose/build.gradle.kts +++ b/app-compose/build.gradle.kts @@ -16,46 +16,7 @@ android { } dependencies { - implementation(projects.presentation) - - implementation(projects.core.android) - implementation(projects.core.model) - implementation(projects.core.common) - implementation(projects.core.network) - implementation(projects.core.security) - implementation(projects.core.database) - implementation(projects.core.ui) - - implementation(projects.remote.openmajor) - implementation(projects.remote.timetable) - implementation(projects.remote.lectureevaluation.viewerreporter) - implementation(projects.remote.lectureevaluation.my) - implementation(projects.remote.lectureevaluation.editor) - implementation(projects.remote.signup) - implementation(projects.remote.notice) - implementation(projects.remote.user) - - implementation(projects.local.openmajor) - implementation(projects.local.timetable) - implementation(projects.local.user) - - implementation(projects.data.openmajor) - implementation(projects.data.timetable) - implementation(projects.data.lectureevaluation.viewerreporter) - implementation(projects.data.lectureevaluation.editor) - implementation(projects.data.lectureevaluation.my) - implementation(projects.data.user) - implementation(projects.data.notice) - implementation(projects.data.signup) - - implementation(projects.domain.openmajor) - implementation(projects.domain.user) - implementation(projects.domain.signup) - implementation(projects.domain.lectureevaluation.viewerreporter) - implementation(projects.domain.lectureevaluation.my) - implementation(projects.domain.lectureevaluation.editor) - implementation(projects.domain.timetable) - implementation(projects.domain.notice) + implementation(projects.feature.navigator) implementation(libs.timber) } diff --git a/build-logic/convention/src/main/java/FeatureComposeConventionPlugin.kt b/build-logic/convention/src/main/java/FeatureComposeConventionPlugin.kt index eaf5459d8..6a785f659 100644 --- a/build-logic/convention/src/main/java/FeatureComposeConventionPlugin.kt +++ b/build-logic/convention/src/main/java/FeatureComposeConventionPlugin.kt @@ -2,6 +2,7 @@ import com.kunize.convention.libs import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.project internal class FeatureComposeConventionPlugin : Plugin { @@ -14,6 +15,11 @@ internal class FeatureComposeConventionPlugin : Plugin { } dependencies { + "implementation"(project(":core:model")) + "implementation"(project(":core:android")) + "implementation"(project(":core:ui")) + "implementation"(project(":core:designsystem")) + "implementation"(libs.findLibrary("kotlinx.coroutines.android").get()) "implementation"(libs.findLibrary("kotlinx.coroutines.core").get()) diff --git a/core/designsystem/src/main/res/values/themes.xml b/core/designsystem/src/main/res/values/themes.xml new file mode 100644 index 000000000..785c47862 --- /dev/null +++ b/core/designsystem/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +