Skip to content

Commit

Permalink
Merge pull request #176 from AII-the-time/feat/#175-test-api
Browse files Browse the repository at this point in the history
[Feat/#175] 가게 등록 test api 추가
  • Loading branch information
915dbfl authored Nov 23, 2023
2 parents 9668376 + 17662f4 commit 2b2b076
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common-ui/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<string name="tv_business_registration_num_hint">ex) 0101234123</string>
<string name="tv_register_store_des">인증에 성공하셨습니다!</string>
<string name="tv_business_registration_num_des1">사업자 등록 번호 입력</string>
<string name="tv_business_registration_num_des2">가게 등록을 위해 사업자등록번호를 입력해주세요!</string>
<string name="tv_business_registration_num_des2">가게 등록을 위해 사업자등록번호를 입력해주세요!\n사업자번호가 없으시다면 <b>0000</b>을 입력해 테스트해보실 수 있습니다!</string>
<string name="tv_store_name_des1">가게 이름 입력</string>
<string name="tv_store_name_des2">추가적인 가게 정보를 알려주세요!</string>
<string name="tv_re_authentication_des">← 전화번호를 재인증 하시겠습니까?</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.swm.att.login.store

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
Expand All @@ -17,7 +15,6 @@ import org.swm.att.domain.entity.response.StoreIdVO
import org.swm.att.domain.entity.response.StoreListVO
import org.swm.att.domain.entity.response.TokenVO
import org.swm.att.domain.repository.AttPosUserRepository
import java.lang.IllegalArgumentException
import javax.inject.Inject

@HiltViewModel
Expand All @@ -31,6 +28,7 @@ class RegisterStoreViewModel @Inject constructor(
val registerStoreState: StateFlow<UiState<StoreIdVO>> = _registerStoreState
private val _getStoreState = MutableStateFlow<UiState<StoreListVO>>(UiState.Loading)
val getStoreState: StateFlow<UiState<StoreListVO>> = _getStoreState
private var businessNumber: String? = null

//login
fun login(businessRegistrationNumber: String, certificatedPhoneToken: String?) {
Expand All @@ -40,6 +38,7 @@ class RegisterStoreViewModel @Inject constructor(
attPosUserRepository.login(userInfo).collect { result ->
result.onSuccess {
_loginState.value = UiState.Success(it)
businessNumber = businessRegistrationNumber
}.onFailure {
val errorMsg = if (it is HttpResponseException) it.message else "사업자 등록 번호 제출에 실패했습니다."
_loginState.value = UiState.Error(errorMsg)
Expand Down Expand Up @@ -79,14 +78,25 @@ class RegisterStoreViewModel @Inject constructor(
viewModelScope.launch(attExceptionHandler) {
try {
val storeInfo = checkCreateStoreInfo(storeName)
attPosUserRepository.registerStoreForTest(storeInfo).collect { result ->
//attPosUserRepository.registerStore(storeInfo).collect { result ->
result.onSuccess {
_registerStoreState.value = UiState.Success(it)
saveStoreId(it.storeId)
}.onFailure {
val errorMsg = if (it is HttpResponseException) it.message else "가게 등록에 실패했습니다."
_registerStoreState.value = UiState.Error(errorMsg)
if (businessNumber == "0000" && storeInfo.name == "소예다방") { // TODO: 테스트 계정 생성을 위한 코드, 추후 삭제 필요
attPosUserRepository.registerStoreForTest(storeInfo).collect { result ->
result.onSuccess {
_registerStoreState.value = UiState.Success(it)
saveStoreId(it.storeId)
}.onFailure {
val errorMsg = if (it is HttpResponseException) it.message else "가게 등록에 실패했습니다."
_registerStoreState.value = UiState.Error(errorMsg)
}
}
} else {
attPosUserRepository.registerStore(storeInfo).collect { result ->
result.onSuccess {
_registerStoreState.value = UiState.Success(it)
saveStoreId(it.storeId)
}.onFailure {
val errorMsg = if (it is HttpResponseException) it.message else "가게 등록에 실패했습니다."
_registerStoreState.value = UiState.Error(errorMsg)
}
}
}
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
app:layout_constraintVertical_chainStyle="packed"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/cl_business_registration_num"
app:layout_constraintEnd_toEndOf="@id/cl_business_registration_num"
app:layout_constraintStart_toStartOf="@id/cl_business_registration_num">

<TextView
Expand Down

0 comments on commit 2b2b076

Please sign in to comment.