generated from AND-SOPT-ANDROID/and-sopt-android-template
-
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.
feat/#8: UserService, DataSource, Repository에 login SignIn api 연결
- Loading branch information
1 parent
1f87147
commit 2ad9f31
Showing
4 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
data/src/main/java/org/sopt/and/data/datasource/AuthDataSource.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 org.sopt.and.data.datasource | ||
|
||
import org.sopt.and.data.common.execute | ||
import org.sopt.and.data.dto.request.SignInRequestDto | ||
import org.sopt.and.data.service.AuthService | ||
import org.sopt.and.domain.exception.Result | ||
import org.sopt.and.domain.model.SignInResponse | ||
import javax.inject.Inject | ||
|
||
internal class AuthDataSource @Inject constructor( | ||
private val authService: AuthService | ||
) { | ||
suspend fun signIn(request: SignInRequestDto): Result<SignInResponse> = execute { | ||
authService.signIn(request).result.toDomainModel() | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
data/src/main/java/org/sopt/and/data/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,17 @@ | ||
package org.sopt.and.data.repository | ||
|
||
import org.sopt.and.data.datasource.AuthDataSource | ||
import org.sopt.and.data.dto.request.toRequestBody | ||
import org.sopt.and.domain.exception.Result | ||
import org.sopt.and.domain.model.SignInRequest | ||
import org.sopt.and.domain.model.SignInResponse | ||
import org.sopt.and.domain.repository.AuthRepository | ||
import javax.inject.Inject | ||
|
||
internal class AuthRepositoryImpl @Inject constructor( | ||
private val authDataSource: AuthDataSource | ||
): AuthRepository { | ||
override suspend fun signIn(request: SignInRequest): Result<SignInResponse> { | ||
return authDataSource.signIn(request.toRequestBody()) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
data/src/main/java/org/sopt/and/data/service/AuthService.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 org.sopt.and.data.service | ||
|
||
import org.sopt.and.data.dto.request.SignInRequestDto | ||
import org.sopt.and.data.dto.BaseResponse | ||
import org.sopt.and.data.dto.response.SignInResponseDto | ||
import retrofit2.http.Body | ||
import retrofit2.http.POST | ||
|
||
internal interface AuthService { | ||
@POST("login") | ||
suspend fun signIn( | ||
@Body request: SignInRequestDto | ||
): BaseResponse<SignInResponseDto> | ||
} |
9 changes: 9 additions & 0 deletions
9
domain/src/main/java/org/sopt/and/domain/repository/AuthRepository.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,9 @@ | ||
package org.sopt.and.domain.repository | ||
|
||
import org.sopt.and.domain.exception.Result | ||
import org.sopt.and.domain.model.SignInRequest | ||
import org.sopt.and.domain.model.SignInResponse | ||
|
||
interface AuthRepository { | ||
suspend fun signIn(request: SignInRequest): Result<SignInResponse> | ||
} |