Skip to content

Commit

Permalink
#298 [chore] 닉네임중복 네이밍 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
2zerozu committed Mar 3, 2024
1 parent 4212f07 commit 93b5929
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Original file line number Diff line number Diff line change
Expand Up @@ -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<Int> =
kotlin.runCatching {
userInputDataSource.postDuplicate(
userInputDataSource.postNicknameDuplicate(
nickname
)
}.map { response -> requireNotNull(response.data).check }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ interface BookService {
@Path("bookshelfId") bookId: Int,
@Body bookComment: EditBookRequest
): NoResponse

@POST("/bookshelf/duplicate")
suspend fun postBookDuplicate()
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,7 +15,7 @@ import retrofit2.http.PartMap

interface UserInputService {
@POST("user/duplicate")
suspend fun postDuplicate(@Body body: DuplicateRequest): BaseResponse<DuplicateResponse>
suspend fun postDuplicate(@Body body: NicknameDuplicateRequest): BaseResponse<NicknameDuplicateResponse>

@Multipart
@PATCH("auth/signup")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<DuplicateResponse> = userInputService.postDuplicate(
DuplicateRequest(
): BaseResponse<NicknameDuplicateResponse> = userInputService.postDuplicate(
NicknameDuplicateRequest(
nickname = nickname
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import okhttp3.MultipartBody
import okhttp3.RequestBody

interface UserInputRepository {
suspend fun postDuplicate(
suspend fun postNicknameDuplicate(
nickname: String
): Result<Int>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Boolean> = MutableLiveData(true)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Boolean> = MutableLiveData(true)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 93b5929

Please sign in to comment.