Skip to content

Commit

Permalink
feat/#8: UserService, DataSource, Repository에 login SignIn api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
kangyein9892 committed Nov 15, 2024
1 parent 1f87147 commit 2ad9f31
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
17 changes: 17 additions & 0 deletions data/src/main/java/org/sopt/and/data/datasource/AuthDataSource.kt
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()
}

}
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 data/src/main/java/org/sopt/and/data/service/AuthService.kt
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>
}
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>
}

0 comments on commit 2ad9f31

Please sign in to comment.