Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: T-477 지도의 카메라를 이동시켰을 경우, 현 지도에서 검색 기능 추가 #278

Merged
merged 12 commits into from
May 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: 유저 닉네임 변경 로직 변경
닉네임만 변경한 경우 내 정보 수정 API 가 아닌, 닉네임 수정 API 호출 하도록 변경
easyhooon committed May 1, 2024
commit da19054f4e25c6247dd1c0b503a2002cef81fb0a
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
package us.wedemy.eggeum.android.data.datasource.user

import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest
import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest
import us.wedemy.eggeum.android.data.model.user.UserInfoResponse

internal interface UserDataSource {
@@ -17,7 +18,7 @@ internal interface UserDataSource {

suspend fun withdraw()

suspend fun updateUserNickname(nickname: String)
suspend fun updateUserNickname(updateUserNicknameRequest: UpdateUserNicknameRequest)

suspend fun checkNicknameExist(nickname: String): Boolean
}
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.data.datasource.user
import javax.inject.Inject
import javax.inject.Singleton
import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest
import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest
import us.wedemy.eggeum.android.data.model.user.UserInfoResponse
import us.wedemy.eggeum.android.data.service.UserService

@@ -29,8 +30,8 @@ internal class UserDataSourceImpl @Inject constructor(
service.withdraw()
}

override suspend fun updateUserNickname(nickname: String) {
service.updateUserNickname(nickname)
override suspend fun updateUserNickname(updateUserNicknameRequest: UpdateUserNicknameRequest) {
service.updateUserNickname(updateUserNicknameRequest)
}

override suspend fun checkNicknameExist(nickname: String): Boolean {
Original file line number Diff line number Diff line change
@@ -9,9 +9,11 @@ package us.wedemy.eggeum.android.data.mapper

import us.wedemy.eggeum.android.data.model.user.User
import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest
import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest
import us.wedemy.eggeum.android.data.model.user.UserInfoResponse
import us.wedemy.eggeum.android.domain.model.report.UserEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity
import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity

internal fun UserInfoResponse.toEntity() =
@@ -32,6 +34,11 @@ internal fun UpdateUserInfoEntity.toModel() =
profileImage = profileImageEntity?.toModel(),
)

internal fun UpdateUserNicknameEntity.toModel() =
UpdateUserNicknameRequest(
nickname = nickname,
)

internal fun User.toEntity() =
UserEntity(
agreeMarketing = agreeMarketing,
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import us.wedemy.eggeum.android.data.datasource.user.UserDataSource
import us.wedemy.eggeum.android.data.mapper.toEntity
import us.wedemy.eggeum.android.data.mapper.toModel
import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity
import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity
import us.wedemy.eggeum.android.domain.repository.UserRepository

@@ -32,8 +33,8 @@ internal class UserRepositoryImpl @Inject constructor(
dataSource.withdraw()
}

override suspend fun updateUserNickname(nickname: String) {
dataSource.updateUserNickname(nickname)
override suspend fun updateUserNickname(updateUserNicknameEntity: UpdateUserNicknameEntity) {
dataSource.updateUserNickname(updateUserNicknameEntity.toModel())
}

override suspend fun checkNicknameExist(nickname: String): Boolean {
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ import retrofit2.http.GET
import retrofit2.http.PUT
import retrofit2.http.Query
import us.wedemy.eggeum.android.data.model.user.UpdateUserInfoRequest
import us.wedemy.eggeum.android.data.model.user.UpdateUserNicknameRequest
import us.wedemy.eggeum.android.data.model.user.UserInfoResponse

internal interface UserService {
@@ -29,7 +30,7 @@ internal interface UserService {

@PUT("app/users/me/nickname")
suspend fun updateUserNickname(
@Body nickname: String,
@Body updateUserNicknameRequest: UpdateUserNicknameRequest,
)

@GET("app/users/nickname/exists")
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Designed and developed by Wedemy 2023.
*
* Licensed under the MIT.
* Please see full license: https://github.com/Wedemy/eggeum-android/blob/main/LICENSE
*/

package us.wedemy.eggeum.android.domain.model.user

public data class UpdateUserNicknameEntity(
val nickname: String,
)
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
package us.wedemy.eggeum.android.domain.repository

import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity
import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity

/** 사용자 API */
@@ -33,9 +34,9 @@ public interface UserRepository {
/**
* 닉네임 수정
*
* @param nickname 닉네임
* @param updateUserNicknameEntity
*/
public suspend fun updateUserNickname(nickname: String)
public suspend fun updateUserNickname(updateUserNicknameEntity: UpdateUserNicknameEntity)

/**
* 닉네임 존재여부 조회
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ package us.wedemy.eggeum.android.domain.usecase
import javax.inject.Inject
import javax.inject.Singleton
import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity
import us.wedemy.eggeum.android.domain.model.user.UserInfoEntity
import us.wedemy.eggeum.android.domain.repository.UserRepository
import us.wedemy.eggeum.android.domain.util.runSuspendCatching
@@ -25,7 +26,7 @@ public class GetUserInfoUseCase @Inject constructor(
}

@Singleton
public class UpdateUserInfoUseCase @Inject constructor(
public class UpdateUserProfileAndNicknameUseCase @Inject constructor(
private val repository: UserRepository,
) {
public suspend operator fun invoke(updateUserInfoEntity: UpdateUserInfoEntity): Result<Unit> =
@@ -48,9 +49,9 @@ public class WithdrawUseCase @Inject constructor(
public class UpdateUserNicknameUseCase @Inject constructor(
private val repository: UserRepository,
) {
public suspend operator fun invoke(nickname: String): Result<Unit> =
public suspend operator fun invoke(updateUserNicknameEntity: UpdateUserNicknameEntity): Result<Unit> =
runSuspendCatching {
repository.updateUserNickname(nickname)
repository.updateUserNickname(updateUserNicknameEntity)
}
}

Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ class EditMyInfoFragment : BaseFragment<FragmentEditMyInfoBinding>() {
}

binding.btnEditMyInfo.setOnClickListener {
viewModel.updateUserNickname()
viewModel.updateUserInfo()
}
}

Original file line number Diff line number Diff line change
@@ -30,18 +30,20 @@ import us.wedemy.eggeum.android.common.util.handleException
import us.wedemy.eggeum.android.domain.model.FileEntity
import us.wedemy.eggeum.android.domain.model.ProfileImageEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserInfoEntity
import us.wedemy.eggeum.android.domain.model.user.UpdateUserNicknameEntity
import us.wedemy.eggeum.android.domain.usecase.CheckNicknameExistUseCase
import us.wedemy.eggeum.android.domain.usecase.LogoutUseCase
import us.wedemy.eggeum.android.domain.usecase.UpdateUserInfoUseCase
import us.wedemy.eggeum.android.domain.usecase.UpdateUserNicknameUseCase
import us.wedemy.eggeum.android.domain.usecase.UpdateUserProfileAndNicknameUseCase
import us.wedemy.eggeum.android.domain.usecase.UploadImageFileUseCase
import us.wedemy.eggeum.android.main.R
import us.wedemy.eggeum.android.main.mapper.toEntity
import us.wedemy.eggeum.android.main.model.UserInfoModel

@HiltViewModel
class EditMyInfoViewModel @Inject constructor(
private val uploadImageFileUseCase: UploadImageFileUseCase,
private val updateUserInfoUseCase: UpdateUserInfoUseCase,
private val updateUserProfileAndNicknameUseCase: UpdateUserProfileAndNicknameUseCase,
private val updateUserNicknameUseCase: UpdateUserNicknameUseCase,
private val checkNicknameExistUseCase: CheckNicknameExistUseCase,
private val logoutUseCase: LogoutUseCase,
savedStateHandle: SavedStateHandle,
@@ -139,28 +141,24 @@ class EditMyInfoViewModel @Inject constructor(
}
}

fun updateUserNickname() {
fun updateUserInfo() {
viewModelScope.launch {
if (newProfileImageUri.value != null && newProfileImageUri.value != userInfo.value.profileImageModel?.files?.get(0)?.url) {
getUploadFileId(newProfileImageUri.value!!)
} else {
updateUserInfoUseCase(
UpdateUserInfoEntity(
nickname = _nickname.value,
profileImageEntity = userInfo.value.profileImageModel?.toEntity(),
),
).onSuccess {
_userInfoUpdateSuccessEvent.emit(Unit)
}.onFailure { exception ->
handleException(exception, this@EditMyInfoViewModel)
}
updateUserNicknameUseCase(UpdateUserNicknameEntity(nickname = _nickname.value))
.onSuccess {
_userInfoUpdateSuccessEvent.emit(Unit)
}.onFailure { exception ->
handleException(exception, this@EditMyInfoViewModel)
}
}
}
}

private fun updateUserProfileAndNickname(file: FileEntity) {
viewModelScope.launch {
updateUserInfoUseCase(
updateUserProfileAndNicknameUseCase(
UpdateUserInfoEntity(
nickname = _nickname.value,
profileImageEntity = ProfileImageEntity(files = listOf(file)),