diff --git a/app/src/main/java/com/sopt/peekabookaos/data/entity/request/DuplicateRequest.kt b/app/src/main/java/com/sopt/peekabookaos/data/entity/request/NicknameDuplicateRequest.kt similarity index 78% rename from app/src/main/java/com/sopt/peekabookaos/data/entity/request/DuplicateRequest.kt rename to app/src/main/java/com/sopt/peekabookaos/data/entity/request/NicknameDuplicateRequest.kt index 22d7e61d..156b2112 100644 --- a/app/src/main/java/com/sopt/peekabookaos/data/entity/request/DuplicateRequest.kt +++ b/app/src/main/java/com/sopt/peekabookaos/data/entity/request/NicknameDuplicateRequest.kt @@ -2,6 +2,6 @@ package com.sopt.peekabookaos.data.entity.request import kotlinx.serialization.Serializable @Serializable -data class DuplicateRequest( +data class NicknameDuplicateRequest( val nickname: String ) diff --git a/app/src/main/java/com/sopt/peekabookaos/data/entity/response/DuplicateResponse.kt b/app/src/main/java/com/sopt/peekabookaos/data/entity/response/NicknameDuplicateResponse.kt similarity index 77% rename from app/src/main/java/com/sopt/peekabookaos/data/entity/response/DuplicateResponse.kt rename to app/src/main/java/com/sopt/peekabookaos/data/entity/response/NicknameDuplicateResponse.kt index ace8a193..75170610 100644 --- a/app/src/main/java/com/sopt/peekabookaos/data/entity/response/DuplicateResponse.kt +++ b/app/src/main/java/com/sopt/peekabookaos/data/entity/response/NicknameDuplicateResponse.kt @@ -3,6 +3,6 @@ package com.sopt.peekabookaos.data.entity.response import kotlinx.serialization.Serializable @Serializable -data class DuplicateResponse( +data class NicknameDuplicateResponse( val check: Int ) diff --git a/app/src/main/java/com/sopt/peekabookaos/data/repository/UserInputRepositoryImpl.kt b/app/src/main/java/com/sopt/peekabookaos/data/repository/UserInputRepositoryImpl.kt index a88b1d06..9379659c 100644 --- a/app/src/main/java/com/sopt/peekabookaos/data/repository/UserInputRepositoryImpl.kt +++ b/app/src/main/java/com/sopt/peekabookaos/data/repository/UserInputRepositoryImpl.kt @@ -9,11 +9,11 @@ import javax.inject.Inject class UserInputRepositoryImpl @Inject constructor( private val userInputDataSource: UserInputDataSource ) : UserInputRepository { - override suspend fun postDuplicate( + override suspend fun postNicknameDuplicate( nickname: String ): Result = kotlin.runCatching { - userInputDataSource.postDuplicate( + userInputDataSource.postNicknameDuplicate( nickname ) }.map { response -> requireNotNull(response.data).check } diff --git a/app/src/main/java/com/sopt/peekabookaos/data/service/BookService.kt b/app/src/main/java/com/sopt/peekabookaos/data/service/BookService.kt index ed264bb1..870707e9 100644 --- a/app/src/main/java/com/sopt/peekabookaos/data/service/BookService.kt +++ b/app/src/main/java/com/sopt/peekabookaos/data/service/BookService.kt @@ -21,4 +21,7 @@ interface BookService { @Path("bookshelfId") bookId: Int, @Body bookComment: EditBookRequest ): NoResponse + + @POST("/bookshelf/duplicate") + suspend fun postBookDuplicate() } diff --git a/app/src/main/java/com/sopt/peekabookaos/data/service/UserInputService.kt b/app/src/main/java/com/sopt/peekabookaos/data/service/UserInputService.kt index a67912e3..5a17d7c5 100644 --- a/app/src/main/java/com/sopt/peekabookaos/data/service/UserInputService.kt +++ b/app/src/main/java/com/sopt/peekabookaos/data/service/UserInputService.kt @@ -2,8 +2,8 @@ package com.sopt.peekabookaos.data.service import com.sopt.peekabookaos.data.entity.BaseResponse import com.sopt.peekabookaos.data.entity.NoResponse -import com.sopt.peekabookaos.data.entity.request.DuplicateRequest -import com.sopt.peekabookaos.data.entity.response.DuplicateResponse +import com.sopt.peekabookaos.data.entity.request.NicknameDuplicateRequest +import com.sopt.peekabookaos.data.entity.response.NicknameDuplicateResponse import okhttp3.MultipartBody import okhttp3.RequestBody import retrofit2.http.Body @@ -15,7 +15,7 @@ import retrofit2.http.PartMap interface UserInputService { @POST("user/duplicate") - suspend fun postDuplicate(@Body body: DuplicateRequest): BaseResponse + suspend fun postDuplicate(@Body body: NicknameDuplicateRequest): BaseResponse @Multipart @PATCH("auth/signup") diff --git a/app/src/main/java/com/sopt/peekabookaos/data/source/remote/UserInputDataSource.kt b/app/src/main/java/com/sopt/peekabookaos/data/source/remote/UserInputDataSource.kt index 048c710b..972e1928 100644 --- a/app/src/main/java/com/sopt/peekabookaos/data/source/remote/UserInputDataSource.kt +++ b/app/src/main/java/com/sopt/peekabookaos/data/source/remote/UserInputDataSource.kt @@ -2,8 +2,8 @@ package com.sopt.peekabookaos.data.source.remote import com.sopt.peekabookaos.data.entity.BaseResponse import com.sopt.peekabookaos.data.entity.NoResponse -import com.sopt.peekabookaos.data.entity.request.DuplicateRequest -import com.sopt.peekabookaos.data.entity.response.DuplicateResponse +import com.sopt.peekabookaos.data.entity.request.NicknameDuplicateRequest +import com.sopt.peekabookaos.data.entity.response.NicknameDuplicateResponse import com.sopt.peekabookaos.data.service.UserInputService import okhttp3.MultipartBody import okhttp3.RequestBody @@ -12,10 +12,10 @@ import javax.inject.Inject data class UserInputDataSource @Inject constructor( private val userInputService: UserInputService ) { - suspend fun postDuplicate( + suspend fun postNicknameDuplicate( nickname: String - ): BaseResponse = userInputService.postDuplicate( - DuplicateRequest( + ): BaseResponse = userInputService.postDuplicate( + NicknameDuplicateRequest( nickname = nickname ) ) diff --git a/app/src/main/java/com/sopt/peekabookaos/domain/repository/UserInputRepository.kt b/app/src/main/java/com/sopt/peekabookaos/domain/repository/UserInputRepository.kt index 90fb1075..83ca7b7e 100644 --- a/app/src/main/java/com/sopt/peekabookaos/domain/repository/UserInputRepository.kt +++ b/app/src/main/java/com/sopt/peekabookaos/domain/repository/UserInputRepository.kt @@ -4,7 +4,7 @@ import okhttp3.MultipartBody import okhttp3.RequestBody interface UserInputRepository { - suspend fun postDuplicate( + suspend fun postNicknameDuplicate( nickname: String ): Result diff --git a/app/src/main/java/com/sopt/peekabookaos/domain/usecase/PostDuplicateUseCase.kt b/app/src/main/java/com/sopt/peekabookaos/domain/usecase/PostNicknameDuplicateUseCase.kt similarity index 54% rename from app/src/main/java/com/sopt/peekabookaos/domain/usecase/PostDuplicateUseCase.kt rename to app/src/main/java/com/sopt/peekabookaos/domain/usecase/PostNicknameDuplicateUseCase.kt index d8952d5f..5c82a493 100644 --- a/app/src/main/java/com/sopt/peekabookaos/domain/usecase/PostDuplicateUseCase.kt +++ b/app/src/main/java/com/sopt/peekabookaos/domain/usecase/PostNicknameDuplicateUseCase.kt @@ -3,8 +3,9 @@ package com.sopt.peekabookaos.domain.usecase import com.sopt.peekabookaos.domain.repository.UserInputRepository import javax.inject.Inject -class PostDuplicateUseCase @Inject constructor( +class PostNicknameDuplicateUseCase @Inject constructor( private val userInputRepository: UserInputRepository ) { - suspend operator fun invoke(nickname: String) = userInputRepository.postDuplicate(nickname) + suspend operator fun invoke(nickname: String) = + userInputRepository.postNicknameDuplicate(nickname) } diff --git a/app/src/main/java/com/sopt/peekabookaos/presentation/profileModify/ProfileModifyViewModel.kt b/app/src/main/java/com/sopt/peekabookaos/presentation/profileModify/ProfileModifyViewModel.kt index 9fdc9183..d26084ee 100644 --- a/app/src/main/java/com/sopt/peekabookaos/presentation/profileModify/ProfileModifyViewModel.kt +++ b/app/src/main/java/com/sopt/peekabookaos/presentation/profileModify/ProfileModifyViewModel.kt @@ -9,7 +9,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.sopt.peekabookaos.domain.entity.User import com.sopt.peekabookaos.domain.usecase.PatchProfileModifyUseCase -import com.sopt.peekabookaos.domain.usecase.PostDuplicateUseCase +import com.sopt.peekabookaos.domain.usecase.PostNicknameDuplicateUseCase import com.sopt.peekabookaos.util.ContentUriRequestBody import com.sopt.peekabookaos.util.ImageUtil import dagger.hilt.android.lifecycle.HiltViewModel @@ -24,7 +24,7 @@ import javax.inject.Inject @HiltViewModel class ProfileModifyViewModel @Inject constructor( private val application: Application, - private val postDuplicateUseCase: PostDuplicateUseCase, + private val postNicknameDuplicateUseCase: PostNicknameDuplicateUseCase, private val patchProfileModifyUseCase: PatchProfileModifyUseCase ) : ViewModel() { private val _isNicknameInUse: MutableLiveData = MutableLiveData(true) @@ -72,7 +72,7 @@ class ProfileModifyViewModel @Inject constructor( fun getNickNameState() { viewModelScope.launch { - postDuplicateUseCase(requireNotNull(nickname.value)) + postNicknameDuplicateUseCase(requireNotNull(nickname.value)) .onSuccess { check -> _isNicknameInUse.value = (check == 1) updateNicknameMessage(true) diff --git a/app/src/main/java/com/sopt/peekabookaos/presentation/userInput/UserInputViewModel.kt b/app/src/main/java/com/sopt/peekabookaos/presentation/userInput/UserInputViewModel.kt index ea446ca5..99d3628e 100644 --- a/app/src/main/java/com/sopt/peekabookaos/presentation/userInput/UserInputViewModel.kt +++ b/app/src/main/java/com/sopt/peekabookaos/presentation/userInput/UserInputViewModel.kt @@ -8,7 +8,7 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.sopt.peekabookaos.domain.usecase.PatchSignUpUseCase -import com.sopt.peekabookaos.domain.usecase.PostDuplicateUseCase +import com.sopt.peekabookaos.domain.usecase.PostNicknameDuplicateUseCase import com.sopt.peekabookaos.util.ContentUriRequestBody import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.launch @@ -22,7 +22,7 @@ import javax.inject.Inject @HiltViewModel class UserInputViewModel @Inject constructor( private val application: Application, - private val postDuplicateUseCase: PostDuplicateUseCase, + private val postNicknameDuplicateUseCase: PostNicknameDuplicateUseCase, private val patchSignUpUseCase: PatchSignUpUseCase ) : ViewModel() { private val _isNickname: MutableLiveData = MutableLiveData(true) @@ -68,7 +68,7 @@ class UserInputViewModel @Inject constructor( fun getNickNameState() { viewModelScope.launch { - postDuplicateUseCase(requireNotNull(nickname.value)) + postNicknameDuplicateUseCase(requireNotNull(nickname.value)) .onSuccess { check -> _isNickname.value = (check == 1) updateNicknameMessage(true)