diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/ApiModule.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/ApiModule.kt index 4431a1f2..ee35a5ed 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/ApiModule.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/ApiModule.kt @@ -1,7 +1,7 @@ package com.avengers.nibobnebob.app.di -import com.avengers.nibobnebob.data.remote.NnApi -import com.avengers.nibobnebob.data.remote.IntroAPI +import com.avengers.nibobnebob.data.remote.MyPageApi +import com.avengers.nibobnebob.data.remote.IntroApi import com.avengers.nibobnebob.data.remote.RefreshApi import com.avengers.nibobnebob.data.remote.ValidationApi import dagger.Module @@ -19,8 +19,8 @@ object ApiModule { @Singleton @Provides - fun provideIntroService(retrofit: Retrofit): IntroAPI { - return retrofit.create(IntroAPI::class.java) + fun provideIntroService(retrofit: Retrofit): IntroApi { + return retrofit.create(IntroApi::class.java) } @Singleton @@ -36,6 +36,6 @@ object ApiModule { } @Singleton @Provides - fun provideNnApi(retrofit: Retrofit) : NnApi = retrofit.create(NnApi::class.java) + fun provideMyPageService(retrofit: Retrofit) : MyPageApi = retrofit.create(MyPageApi::class.java) } \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/DataModule.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/DataModule.kt index dd77a0e8..0b0b7ebe 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/DataModule.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/DataModule.kt @@ -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 } \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/RepositoryModule.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/RepositoryModule.kt index 4205b159..2fd1f5c8 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/RepositoryModule.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/app/di/RepositoryModule.kt @@ -1,8 +1,10 @@ package com.avengers.nibobnebob.app.di -import com.avengers.nibobnebob.data.repository.MyPageEditRepository +import com.avengers.nibobnebob.data.repository.IntroRepository +import com.avengers.nibobnebob.data.repository.IntroRepositoryImpl import com.avengers.nibobnebob.data.repository.MyPageRepository -import com.avengers.nibobnebob.data.repository_impl.MyPageEditRepositoryImpl +import com.avengers.nibobnebob.data.repository.ValidationRepository +import com.avengers.nibobnebob.data.repository.ValidationRepositoryImpl import com.avengers.nibobnebob.data.repository_impl.MyPageRepositoryImpl import dagger.Binds import dagger.Module @@ -19,10 +21,6 @@ abstract class RepositoryModule { @Binds abstract fun bindMyPageRepository(myPageRepositoryImpl: MyPageRepositoryImpl): MyPageRepository - @Singleton - @Binds - abstract fun bindMyPageEditRepository(myPageRepositoryImpl: MyPageEditRepositoryImpl): MyPageEditRepository - @Singleton @Binds abstract fun bindIntroRepository( diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/request/MyPageEditInfoRequest.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/request/EditMyInfoRequest.kt similarity index 87% rename from Aos/app/src/main/java/com/avengers/nibobnebob/data/model/request/MyPageEditInfoRequest.kt rename to Aos/app/src/main/java/com/avengers/nibobnebob/data/model/request/EditMyInfoRequest.kt index ade3d8b3..98f68cb4 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/request/MyPageEditInfoRequest.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/request/EditMyInfoRequest.kt @@ -1,6 +1,6 @@ package com.avengers.nibobnebob.data.model.request -data class MyPageEditInfoRequest( +data class EditMyInfoRequest( val nickName: String, val email: String, val provider: String, diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/BasicResponse.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/BasicResponse.kt deleted file mode 100644 index a018f9e0..00000000 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/BasicResponse.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.avengers.nibobnebob.data.model.response - -data class BasicResponse( - val data: Any?, - val message: String, - val statusCode: Int -) diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/CheckSameNickResponse.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/CheckSameNickResponse.kt deleted file mode 100644 index 3d34eacc..00000000 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/CheckSameNickResponse.kt +++ /dev/null @@ -1,13 +0,0 @@ -package com.avengers.nibobnebob.data.model.response - -import com.google.gson.annotations.SerializedName - -data class CheckSameNickResponse( - val data: CheckSameNick, - val message: String, - val statusCode: Int -) - -data class CheckSameNick( - @SerializedName("isexist") val isExist : Boolean -) diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyPageEditInfoResponse.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyDefaultInfoResponse.kt similarity index 66% rename from Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyPageEditInfoResponse.kt rename to Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyDefaultInfoResponse.kt index d88d8d1b..ef6dc870 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyPageEditInfoResponse.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyDefaultInfoResponse.kt @@ -1,14 +1,8 @@ package com.avengers.nibobnebob.data.model.response -data class MyPageEditInfoResponse( - val data: MyPageEditInfo, - val message: String, - val statusCode: Int -) - -data class MyPageEditInfo( +data class MyDefaultInfoResponse( val userInfo: UserEditInfo ) diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyPageInfoResponse.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyInfoResponse.kt similarity index 61% rename from Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyPageInfoResponse.kt rename to Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyInfoResponse.kt index 0cc4c041..6a74527a 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyPageInfoResponse.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/model/response/MyInfoResponse.kt @@ -1,14 +1,7 @@ package com.avengers.nibobnebob.data.model.response -data class MyPageInfoResponse( - val data: MyPageInfo, - val message: String, - val statusCode: Int -) - - -data class MyPageInfo( +data class MyInfoResponse( val userInfo: UserInfo ) diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/IntroAPI.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/IntroApi.kt similarity index 95% rename from Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/IntroAPI.kt rename to Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/IntroApi.kt index 00f8dcda..6086bc38 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/IntroAPI.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/IntroApi.kt @@ -6,7 +6,7 @@ import retrofit2.Response import retrofit2.http.Body import retrofit2.http.POST -interface IntroAPI { +interface IntroApi { @POST("/api/user") suspend fun signup( diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/MyPageApi.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/MyPageApi.kt new file mode 100644 index 00000000..103d2d9b --- /dev/null +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/MyPageApi.kt @@ -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 + + @GET("api/user") + suspend fun getMyDefaultInfo( + @Header("Authorization") token : String, + ) : Response + + @PUT("api/user") + suspend fun editMyInfo( + @Header("Authorization") token : String, + @Body data : EditMyInfoRequest + ) : Response + +} \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/NnApi.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/NnApi.kt deleted file mode 100644 index 056d418f..00000000 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/remote/NnApi.kt +++ /dev/null @@ -1,36 +0,0 @@ -package com.avengers.nibobnebob.data.remote - -import com.avengers.nibobnebob.data.model.request.MyPageEditInfoRequest -import com.avengers.nibobnebob.data.model.response.BasicResponse -import com.avengers.nibobnebob.data.model.response.CheckSameNickResponse -import com.avengers.nibobnebob.data.model.response.MyPageEditInfoResponse -import com.avengers.nibobnebob.data.model.response.MyPageInfoResponse -import retrofit2.Response -import retrofit2.http.Body -import retrofit2.http.GET -import retrofit2.http.Header -import retrofit2.http.PUT -import retrofit2.http.Path - -interface NnApi { - @GET("api/user/details") - suspend fun getMyPageInfo( - @Header("Authorization") token : String, - ) : Response - - @GET("api/user") - suspend fun getMyPageEditInfo( - @Header("Authorization") token : String, - ) : Response - - @PUT("api/user") - suspend fun putMyPageEditInfo( - @Header("Authorization") token : String, - @Body data : MyPageEditInfoRequest - ) : Response - - @GET("api/user/nickname/{nickname}/exists") - suspend fun getCheckSameNickname( - @Path("nickname") nick : String - ) : Response -} \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/IntroRepositoryImpl.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/IntroRepositoryImpl.kt index ae33a7a2..6e3ae20f 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/IntroRepositoryImpl.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/IntroRepositoryImpl.kt @@ -4,13 +4,13 @@ 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 com.avengers.nibobnebob.data.remote.IntroApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import javax.inject.Inject class IntroRepositoryImpl @Inject constructor( - private val api: IntroAPI + private val api: IntroApi ) : IntroRepository { override fun signup(body: DetailSignupRequest): Flow> = flow { diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageEditRepository.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageEditRepository.kt deleted file mode 100644 index 07cca9e8..00000000 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageEditRepository.kt +++ /dev/null @@ -1,16 +0,0 @@ -package com.avengers.nibobnebob.data.repository - -import com.avengers.nibobnebob.data.model.ApiState -import com.avengers.nibobnebob.data.model.request.MyPageEditInfoRequest -import com.avengers.nibobnebob.data.model.response.BasicResponse -import com.avengers.nibobnebob.data.model.response.CheckSameNickResponse -import com.avengers.nibobnebob.data.model.response.MyPageEditInfoResponse -import kotlinx.coroutines.flow.Flow - -interface MyPageEditRepository { - fun getMyPageEditInfo(): Flow> - - fun putMyPageEditInfo(data: MyPageEditInfoRequest): Flow> - - fun getCheckNickname(nick: String): Flow> -} \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageRepository.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageRepository.kt index 75f3b3ab..41a94fd3 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageRepository.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository/MyPageRepository.kt @@ -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> + fun getMyInfo(): Flow> + + fun getMyDefaultInfo(): Flow> + + fun editMyInfo(data: EditMyInfoRequest): Flow> + } \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageEditRepositoryImpl.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageEditRepositoryImpl.kt deleted file mode 100644 index 235c8564..00000000 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageEditRepositoryImpl.kt +++ /dev/null @@ -1,58 +0,0 @@ -package com.avengers.nibobnebob.data.repository_impl - -import com.avengers.nibobnebob.data.model.ApiState -import com.avengers.nibobnebob.data.model.request.MyPageEditInfoRequest -import com.avengers.nibobnebob.data.model.response.BasicResponse -import com.avengers.nibobnebob.data.model.response.CheckSameNickResponse -import com.avengers.nibobnebob.data.model.response.MyPageEditInfoResponse -import com.avengers.nibobnebob.data.remote.NnApi -import com.avengers.nibobnebob.data.repository.MyPageEditRepository -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import javax.inject.Inject - -class MyPageEditRepositoryImpl @Inject constructor(private val nnApi: NnApi) : - MyPageEditRepository { - private val token = - "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWQiOjIsImlhdCI6MjAxNjIzOTAyMn0.VMvtPcawKVzNyOV08lrArxUvM-XxowWIknsPFkjRTws" - - override fun getMyPageEditInfo(): Flow> = flow { - // 여기는 함수 만들어서 빼면 될듯 - try { - val response = nnApi.getMyPageEditInfo(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 putMyPageEditInfo(data : MyPageEditInfoRequest): Flow> = flow { - try { - val response = nnApi.putMyPageEditInfo(token, data) - 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 getCheckNickname(nick: String): Flow> = flow { - try { - val response = nnApi.getCheckSameNickname(nick) - if(response.isSuccessful){ - emit(ApiState.Success(response.body()!!)) - }else{ - emit(ApiState.Error(response.code(), response.message())) - } - }catch (e : Exception){ - emit(ApiState.Exception(e)) - } - } -} \ No newline at end of file diff --git a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageRepositoryImpl.kt b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageRepositoryImpl.kt index e4cede61..c113954a 100644 --- a/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageRepositoryImpl.kt +++ b/Aos/app/src/main/java/com/avengers/nibobnebob/data/repository_impl/MyPageRepositoryImpl.kt @@ -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> = 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> = flow { + val result = runNNApi { api.getMyInfo(token) } + emit(result) } + override fun getMyDefaultInfo(): Flow> = flow { + val result = runNNApi { api.getMyDefaultInfo(token) } + emit(result) + } + + override fun editMyInfo(data: EditMyInfoRequest): Flow> = flow { + val result = runNNApi { api.editMyInfo(token, data) } + emit(result) + } + } \ No newline at end of file