-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Feature/jaino/#15
- Loading branch information
Showing
26 changed files
with
395 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
...ata/repository/di/AuthRepositoryModule.kt → ...wapp/core/data/di/AuthRepositoryModule.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
19 changes: 19 additions & 0 deletions
19
core/data/src/main/java/com/wap/wapp/core/data/di/DataModule.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,19 @@ | ||
package com.wap.wapp.core.data.di | ||
|
||
import com.wap.wapp.core.data.repository.user.UserRepository | ||
import com.wap.wapp.core.data.repository.user.UserRepositoryImpl | ||
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 DataModule { | ||
@Binds | ||
@Singleton | ||
abstract fun providesUserRepository( | ||
userRepositoryImpl: UserRepositoryImpl, | ||
): UserRepository | ||
} |
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
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
14 changes: 14 additions & 0 deletions
14
core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepository.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,14 @@ | ||
package com.wap.wapp.core.data.repository.user | ||
|
||
import com.wap.wapp.core.model.user.UserProfile | ||
|
||
interface UserRepository { | ||
suspend fun getUserProfile(userId: String): Result<UserProfile> | ||
|
||
suspend fun postUserProfile( | ||
userId: String, | ||
userName: String, | ||
studentId: String, | ||
registeredAt: String, | ||
): Result<Unit> | ||
} |
32 changes: 32 additions & 0 deletions
32
core/data/src/main/java/com/wap/wapp/core/data/repository/user/UserRepositoryImpl.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,32 @@ | ||
package com.wap.wapp.core.data.repository.user | ||
|
||
import com.wap.wapp.core.model.user.UserProfile | ||
import com.wap.wapp.core.network.model.user.UserProfileRequest | ||
import com.wap.wapp.core.network.source.user.UserDataSource | ||
import javax.inject.Inject | ||
|
||
class UserRepositoryImpl @Inject constructor( | ||
private val userDataSource: UserDataSource, | ||
) : UserRepository { | ||
override suspend fun getUserProfile(userId: String): Result<UserProfile> { | ||
return userDataSource.getUserProfile(userId).mapCatching { response -> | ||
response.toDomain() | ||
} | ||
} | ||
|
||
override suspend fun postUserProfile( | ||
userId: String, | ||
userName: String, | ||
studentId: String, | ||
registeredAt: String, | ||
): Result<Unit> { | ||
return userDataSource.postUserProfile( | ||
UserProfileRequest( | ||
userId = userId, | ||
userName = userName, | ||
studentId = studentId, | ||
registeredAt = registeredAt, | ||
), | ||
) | ||
} | ||
} |
13 changes: 0 additions & 13 deletions
13
core/domain/src/main/java/com/wap/wapp/core/domain/auth/SignInUseCase.kt
This file was deleted.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
core/domain/src/main/java/com/wap/wapp/core/domain/model/AuthState.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,5 @@ | ||
package com.wap.wapp.core.domain.model | ||
|
||
enum class AuthState { | ||
SIGN_IN, SIGN_UP | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/DeleteUserUseCase.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,13 @@ | ||
package com.wap.wapp.core.domain.usecase.auth | ||
|
||
import com.wap.wapp.core.data.repository.auth.AuthRepository | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class DeleteUserUseCase @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
) { | ||
suspend operator fun invoke(): Result<Unit> = | ||
authRepository.deleteUser() | ||
} |
38 changes: 38 additions & 0 deletions
38
core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignInUseCase.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,38 @@ | ||
package com.wap.wapp.core.domain.usecase.auth | ||
|
||
import com.wap.wapp.core.data.repository.auth.AuthRepository | ||
import com.wap.wapp.core.data.repository.user.UserRepository | ||
import com.wap.wapp.core.domain.model.AuthState | ||
import com.wap.wapp.core.domain.model.AuthState.SIGN_IN | ||
import com.wap.wapp.core.domain.model.AuthState.SIGN_UP | ||
import dagger.hilt.android.scopes.ActivityScoped | ||
import javax.inject.Inject | ||
|
||
@ActivityScoped | ||
class SignInUseCase @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
private val userRepository: UserRepository, | ||
) { | ||
suspend operator fun invoke(email: String): Result<AuthState> { | ||
return runCatching { | ||
val userId = authRepository.signIn(email) | ||
.getOrThrow() | ||
|
||
userRepository.getUserProfile(userId) | ||
.fold( | ||
onFailure = { exception -> | ||
// 사용자를 조회할 수 없는 예외인 경우 | ||
val userNotFoundException = IllegalStateException() | ||
if (exception == userNotFoundException) { | ||
SIGN_UP | ||
} | ||
// 이외의 예외라면, | ||
throw (exception) | ||
}, | ||
onSuccess = { | ||
SIGN_IN | ||
}, | ||
) | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
core/domain/src/main/java/com/wap/wapp/core/domain/usecase/auth/SignOutUseCase.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,13 @@ | ||
package com.wap.wapp.core.domain.usecase.auth | ||
|
||
import com.wap.wapp.core.data.repository.auth.AuthRepository | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class SignOutUseCase @Inject constructor( | ||
private val authRepository: AuthRepository, | ||
) { | ||
suspend operator fun invoke(): Result<Unit> = | ||
authRepository.signOut() | ||
} |
24 changes: 24 additions & 0 deletions
24
core/domain/src/main/java/com/wap/wapp/core/domain/usecase/user/PostUserProfileUseCase.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,24 @@ | ||
package com.wap.wapp.core.domain.usecase.user | ||
|
||
import com.wap.wapp.core.data.repository.user.UserRepository | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class PostUserProfileUseCase @Inject constructor( | ||
private val userRepository: UserRepository, | ||
) { | ||
suspend operator fun invoke( | ||
userId: String, | ||
userName: String, | ||
studentId: String, | ||
registeredAt: String, | ||
): Result<Unit> { | ||
return userRepository.postUserProfile( | ||
userId = userId, | ||
userName = userName, | ||
studentId = studentId, | ||
registeredAt = registeredAt, | ||
) | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
.../core/network/model/auth/SignUpRequest.kt → ...m/wap/wapp/core/model/user/UserProfile.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
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
6 changes: 6 additions & 0 deletions
6
core/network/src/main/java/com/wap/wapp/core/network/constant/FirebaseConstant.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,6 @@ | ||
package com.wap.wapp.core.network.constant | ||
|
||
/* | ||
파이어스토어 유저 컬렉션 | ||
*/ | ||
const val USER_COLLECTION = "users" |
15 changes: 15 additions & 0 deletions
15
core/network/src/main/java/com/wap/wapp/core/network/model/user/UserProfileRequest.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,15 @@ | ||
package com.wap.wapp.core.network.model.user | ||
|
||
data class UserProfileRequest( | ||
val userId: String, | ||
val userName: String, | ||
val studentId: String, | ||
val registeredAt: String, | ||
) { | ||
constructor() : this( | ||
"", | ||
"", | ||
"", | ||
"", | ||
) | ||
} |
Oops, something went wrong.