-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#86 refactor : Merge 후 Data layer 구조 통일
- Loading branch information
Showing
16 changed files
with
78 additions
and
177 deletions.
There are no files selected for viewing
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
7 changes: 6 additions & 1 deletion
7
Aos/app/src/main/java/com/avengers/nibobnebob/app/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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
package com.avengers.nibobnebob.app.di | ||
|
||
import android.content.Context | ||
import com.avengers.nibobnebob.app.App.Companion.dataStore | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object DataModule { | ||
|
||
@Provides | ||
fun provideDataStore(@ApplicationContext context: Context) = context.dataStore | ||
} |
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
...ta/model/request/MyPageEditInfoRequest.kt → ...b/data/model/request/EditMyInfoRequest.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
7 changes: 0 additions & 7 deletions
7
Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/BasicResponse.kt
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/CheckSameNickResponse.kt
This file was deleted.
Oops, something went wrong.
8 changes: 1 addition & 7 deletions
8
.../model/response/MyPageEditInfoResponse.kt → ...a/model/response/MyDefaultInfoResponse.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
9 changes: 1 addition & 8 deletions
9
...data/model/response/MyPageInfoResponse.kt → ...bob/data/model/response/MyInfoResponse.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
29 changes: 29 additions & 0 deletions
29
Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/MyPageApi.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,29 @@ | ||
package com.avengers.nibobnebob.data.remote | ||
|
||
import com.avengers.nibobnebob.data.model.request.EditMyInfoRequest | ||
import com.avengers.nibobnebob.data.model.response.MyDefaultInfoResponse | ||
import com.avengers.nibobnebob.data.model.response.MyInfoResponse | ||
import retrofit2.Response | ||
import retrofit2.http.Body | ||
import retrofit2.http.GET | ||
import retrofit2.http.Header | ||
import retrofit2.http.PUT | ||
|
||
interface MyPageApi { | ||
@GET("api/user/details") | ||
suspend fun getMyInfo( | ||
@Header("Authorization") token : String, | ||
) : Response<MyInfoResponse> | ||
|
||
@GET("api/user") | ||
suspend fun getMyDefaultInfo( | ||
@Header("Authorization") token : String, | ||
) : Response<MyDefaultInfoResponse> | ||
|
||
@PUT("api/user") | ||
suspend fun editMyInfo( | ||
@Header("Authorization") token : String, | ||
@Body data : EditMyInfoRequest | ||
) : Response<Unit> | ||
|
||
} |
36 changes: 0 additions & 36 deletions
36
Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/NnApi.kt
This file was deleted.
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
16 changes: 0 additions & 16 deletions
16
Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageEditRepository.kt
This file was deleted.
Oops, something went wrong.
11 changes: 9 additions & 2 deletions
11
Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageRepository.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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
package com.avengers.nibobnebob.data.repository | ||
|
||
import com.avengers.nibobnebob.data.model.ApiState | ||
import com.avengers.nibobnebob.data.model.response.MyPageInfoResponse | ||
import com.avengers.nibobnebob.data.model.request.EditMyInfoRequest | ||
import com.avengers.nibobnebob.data.model.response.MyDefaultInfoResponse | ||
import com.avengers.nibobnebob.data.model.response.MyInfoResponse | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface MyPageRepository { | ||
fun getMyPageInfo(): Flow<ApiState<MyPageInfoResponse>> | ||
fun getMyInfo(): Flow<ApiState<MyInfoResponse>> | ||
|
||
fun getMyDefaultInfo(): Flow<ApiState<MyDefaultInfoResponse>> | ||
|
||
fun editMyInfo(data: EditMyInfoRequest): Flow<ApiState<Unit>> | ||
|
||
} |
58 changes: 0 additions & 58 deletions
58
...pp/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageEditRepositoryImpl.kt
This file was deleted.
Oops, something went wrong.
33 changes: 19 additions & 14 deletions
33
Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageRepositoryImpl.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 |
---|---|---|
@@ -1,27 +1,32 @@ | ||
package com.avengers.nibobnebob.data.repository_impl | ||
|
||
import com.avengers.nibobnebob.data.model.ApiState | ||
import com.avengers.nibobnebob.data.model.response.MyPageInfoResponse | ||
import com.avengers.nibobnebob.data.remote.NnApi | ||
import com.avengers.nibobnebob.data.model.request.EditMyInfoRequest | ||
import com.avengers.nibobnebob.data.model.response.MyDefaultInfoResponse | ||
import com.avengers.nibobnebob.data.model.response.MyInfoResponse | ||
import com.avengers.nibobnebob.data.model.runNNApi | ||
import com.avengers.nibobnebob.data.remote.MyPageApi | ||
import com.avengers.nibobnebob.data.repository.MyPageRepository | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.flow | ||
import javax.inject.Inject | ||
|
||
class MyPageRepositoryImpl @Inject constructor(private val nnApi: NnApi) : MyPageRepository { | ||
class MyPageRepositoryImpl @Inject constructor(private val api: MyPageApi) : MyPageRepository { | ||
private val token = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWQiOjIsImlhdCI6MjAxNjIzOTAyMn0.VMvtPcawKVzNyOV08lrArxUvM-XxowWIknsPFkjRTws" | ||
override fun getMyPageInfo(): Flow<ApiState<MyPageInfoResponse>> = flow { | ||
try { | ||
val response = nnApi.getMyPageInfo(token) | ||
if(response.isSuccessful){ | ||
emit(ApiState.Success(response.body()!!)) | ||
}else{ | ||
emit(ApiState.Error(response.code(), response.message())) | ||
} | ||
}catch (e: Exception) { | ||
emit(ApiState.Exception(e)) | ||
} | ||
override fun getMyInfo(): Flow<ApiState<MyInfoResponse>> = flow { | ||
val result = runNNApi { api.getMyInfo(token) } | ||
emit(result) | ||
|
||
} | ||
|
||
override fun getMyDefaultInfo(): Flow<ApiState<MyDefaultInfoResponse>> = flow { | ||
val result = runNNApi { api.getMyDefaultInfo(token) } | ||
emit(result) | ||
} | ||
|
||
override fun editMyInfo(data: EditMyInfoRequest): Flow<ApiState<Unit>> = flow { | ||
val result = runNNApi { api.editMyInfo(token, data) } | ||
emit(result) | ||
} | ||
|
||
} |