Skip to content

Commit

Permalink
#86 refactor : Merge 후 Data Layer 구조 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
plashdof committed Nov 21, 2023
1 parent 0884d03 commit 85e0bfa
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.avengers.nibobnebob.app.di

import com.avengers.nibobnebob.data.remote.NibobNebobApi
import com.avengers.nibobnebob.data.remote.IntroAPI
import com.avengers.nibobnebob.data.remote.RefreshApi
import com.avengers.nibobnebob.data.remote.ValidationApi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import retrofit2.Retrofit
import javax.inject.Singleton


Expand All @@ -28,9 +27,11 @@ object ApiModule {
fun provideValidationService(retrofit: Retrofit): ValidationApi {
return retrofit.create(ValidationApi::class.java)
}

@Singleton
@Provides
fun provideNibobNebobService(retrofit: Retrofit) : NibobNebobApi {
return retrofit.create(NibobNebobApi::class.java)
fun provideRefreshService(retrofit: Retrofit): RefreshApi {
return retrofit.create(RefreshApi::class.java)
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package com.avengers.nibobnebob.app.di

import com.avengers.nibobnebob.data.repository.IntroRepository
import com.avengers.nibobnebob.data.repository.IntroRepositoryImpl
import com.avengers.nibobnebob.data.repository.ValidationRepository
import com.avengers.nibobnebob.data.repository.ValidationRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
Expand All @@ -12,7 +17,7 @@ abstract class RepositoryModule {

@Singleton
@Binds
abstract fun bindImageRepository(
abstract fun bindIntroRepository(
introRepositoryImpl: IntroRepositoryImpl
): IntroRepository

Expand All @@ -22,11 +27,6 @@ abstract class RepositoryModule {
validationRepositoryImpl: ValidationRepositoryImpl
): ValidationRepository

@Singleton
@Binds
abstract fun bindLoginRepository(
loginRepositoryImpl : LoginRepositoryImpl
) : LoginRepository

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ package com.avengers.nibobnebob.data.model.response

import com.google.gson.annotations.SerializedName

data class NaverLoginResponse(
@SerializedName("data") val data : NaverLoginInfo,
@SerializedName("message") val message : String,
@SerializedName("statusCode") val statusCode : String
)

data class NaverLoginInfo(
data class NaverLoginResponse(
@SerializedName("accessToken") val accessToken : String?,
@SerializedName("refreshToken") val refreshToken : String?
)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.avengers.nibobnebob.data.remote

import com.avengers.nibobnebob.data.model.request.DetailSignupRequest
import com.avengers.nibobnebob.data.model.response.NaverLoginResponse
import retrofit2.Response
import retrofit2.http.Body
import retrofit2.http.POST
Expand All @@ -12,4 +13,6 @@ interface IntroAPI {
@Body params: DetailSignupRequest
): Response<Unit>

@POST("api/auth/social-login")
suspend fun loginNaver(): Response<NaverLoginResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ import com.avengers.nibobnebob.data.model.response.NaverLoginResponse
import retrofit2.Response
import retrofit2.http.POST

interface NibobNebobApi {

@POST("api/auth/social-login")
suspend fun postNaverLogin(): Response<NaverLoginResponse>
interface RefreshApi {

@POST("토큰 갱신 url")
suspend fun refreshToken(refreshToken : String) : Response<NaverLoginResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package com.avengers.nibobnebob.data.repository

import com.avengers.nibobnebob.data.model.ApiState
import com.avengers.nibobnebob.data.model.request.DetailSignupRequest
import com.avengers.nibobnebob.data.model.response.NaverLoginResponse
import kotlinx.coroutines.flow.Flow

interface IntroRepository {

fun signup(
body: DetailSignupRequest
): Flow<ApiState<Unit>>

fun loginNaver(): Flow<ApiState<NaverLoginResponse>>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.avengers.nibobnebob.data.repository

import com.avengers.nibobnebob.data.model.ApiState
import com.avengers.nibobnebob.data.model.request.DetailSignupRequest
import com.avengers.nibobnebob.data.model.response.NaverLoginResponse
import com.avengers.nibobnebob.data.model.runNNApi
import com.avengers.nibobnebob.data.remote.IntroAPI
import kotlinx.coroutines.flow.Flow
Expand All @@ -16,4 +17,9 @@ class IntroRepositoryImpl @Inject constructor(
val result = runNNApi { api.signup(body) }
emit(result)
}

override fun loginNaver(): Flow<ApiState<NaverLoginResponse>> = flow {
val result = runNNApi { api.loginNaver() }
emit(result)
}
}

This file was deleted.

This file was deleted.

0 comments on commit 85e0bfa

Please sign in to comment.