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

[FEAT/#127] 서버 점검 API 구현 #128

Merged
merged 9 commits into from
Sep 9, 2024
19 changes: 13 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ android {
manifestPlaceholders["NATIVE_APP_KEY"] =
gradleLocalProperties(rootDir).getProperty("nativeAppKey")

buildConfigField(
"String",
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("base.url"),
)

buildConfigField(
"String",
"IAMPORT_BASE_URL",
Expand All @@ -46,7 +40,20 @@ android {
}

buildTypes {
debug {
buildConfigField(
"String",
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("dev.base.url"),
)
}
release {
buildConfigField(
"String",
"BASE_URL",
gradleLocalProperties(rootDir).getProperty("base.url"),
)

isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<string name="menu_tv_home">홈</string>
<string name="menu_tv_profile">마이페이지</string>

<string name="server_check_tv_title">서버 점검 안내</string>
<string name="server_check_tv_subtitle">서비스 안정화를 위해 점검 진행 중입니다.\n빠른 시간 내에 안정화 할 수 있도록 노력하겠습니다.</string>
<string name="server_check_btn_quit">종료하기</string>

<string name="home_btn_sell">판매하기</string>

<string name="ex_item_title">퓨어 오일 퍼퓸 10 ml 긴제목테스트트트트트</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ interface AuthDataSource {
accesstoken: String,
request: SignUpRequestDto,
): BaseResponse<SignUpDto>

suspend fun getServerStatus(): BaseResponse<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ data class AuthDataSourceImpl
accesstoken: String,
request: SignUpRequestDto,
): BaseResponse<SignUpDto> = authService.postToSignUp(accesstoken, request)

override suspend fun getServerStatus(): BaseResponse<Boolean> = authService.getServerStatus()
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ data class AuthRequestDto(
val token: String,
@SerialName("type")
val type: String,
@SerialName("deviceToken")
@SerialName("devicetoken")
val deviceToken: String,
@SerialName("deviceType")
val deviceType: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@ import kotlinx.serialization.Serializable

@Serializable
data class OrderRequestDto(
@SerialName("itemId")
val itemId: String,
@SerialName("orderId")
val orderId: String,
@SerialName("selectedOptionDetailIdList")
val selectedOptionDetailIdList: List<Long>,
) {
companion object {
fun OrderRequestModel.toDto() = OrderRequestDto(itemId, orderId, selectedOptionDetailIdList)
fun OrderRequestModel.toDto() = OrderRequestDto(orderId, selectedOptionDetailIdList)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ data class SignUpRequestDto(
val sex: String,
@SerialName("isAgreedMarketingTerm")
val isAgreedMarketingTerm: Boolean,
@SerialName("ci")
val ci: String,
) {
companion object {
fun SignUpRequestModel.toDto() = SignUpRequestDto(name, phone, birth, sex, isAgreedMarketingTerm)
fun SignUpRequestModel.toDto() = SignUpRequestDto(name, phone, birth, sex, isAgreedMarketingTerm, ci)
}
}
1 change: 1 addition & 0 deletions data/src/main/java/co/orange/data/local/UserSharedPref.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface UserSharedPref {
var deviceToken: String
var userName: String
var userPhone: String
var userStatus: String

fun clearInfo()
}
5 changes: 5 additions & 0 deletions data/src/main/java/co/orange/data/local/UserSharedPrefImpl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class UserSharedPrefImpl
get() = dataStore.getString(USER_PHONE, "").orEmpty()
set(value) = dataStore.edit { putString(USER_PHONE, value) }

override var userStatus: String
get() = dataStore.getString(USER_STATUS, "").orEmpty()
set(value) = dataStore.edit { putString(USER_STATUS, value) }

override fun clearInfo() {
dataStore.edit().clear().apply()
}
Expand All @@ -39,5 +43,6 @@ class UserSharedPrefImpl
private const val DEVICE_TOKEN = "DEVICE_TOKEN"
private const val USER_NAME = "USER_NAME"
private const val USER_PHONE = "USER_PHONE"
private const val USER_STATUS = "USER_STATUS"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class AuthRepositoryImpl
).data.toModel()
}

override suspend fun getServerStatus(): Result<Boolean> =
runCatching {
authDataSource.getServerStatus().data
}

companion object {
private const val BEARER = "Bearer"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ class UserRepositoryImpl
userSharedPref.userPhone = userPhone
}

override fun getUserRegistered(): Boolean = userSharedPref.userStatus == USER_REGISTERED

override fun setUserStatus(status: String) {
userSharedPref.userStatus = status
}

override fun clearInfo() {
userSharedPref.clearInfo()
}

companion object {
const val USER_REGISTERED = "ACTIVATE"
}
}
4 changes: 4 additions & 0 deletions data/src/main/java/co/orange/data/service/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import co.orange.data.dto.response.AuthTokenDto
import co.orange.data.dto.response.ReissueTokenDto
import co.orange.data.dto.response.SignUpDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.POST

Expand All @@ -27,4 +28,7 @@ interface AuthService {
@Header("Authorization") accesstoken: String,
@Body request: SignUpRequestDto,
): BaseResponse<SignUpDto>

@GET("/api/v1/health")
suspend fun getServerStatus(): BaseResponse<Boolean>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package co.orange.domain.entity.request

data class OrderRequestModel(
val itemId: String,
val orderId: String,
val selectedOptionDetailIdList: List<Long>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ data class SignUpRequestModel(
val birth: String,
val sex: String,
val isAgreedMarketingTerm: Boolean,
val ci: String,
)
9 changes: 7 additions & 2 deletions domain/src/main/kotlin/co/orange/domain/enums/OrderStatus.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package co.orange.domain.enums

enum class OrderStatus {
ORDER_PLACED, SHIPPING, COMPLETED, CANCELLED
}
ORDER_PLACED,
SHIPPING,
DELAYED_SHIPPING,
WARNING,
COMPLETED,
CANCELLED,
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ interface AuthRepository {
accesstoken: String,
request: SignUpRequestModel,
): Result<SignUpModel>

suspend fun getServerStatus(): Result<Boolean>
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ interface UserRepository {
userPhone: String,
)

fun getUserRegistered(): Boolean

fun setUserStatus(status: String)

fun clearInfo()
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class LoginViewModel
)
.onSuccess {
userRepository.setTokens(it.accesstoken, it.refreshtoken)
userRepository.setUserStatus(it.status)
_changeTokenState.value = UiState.Success(it.status)
}
.onFailure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class PhoneViewModel
birth = it.birthday.orEmpty(),
sex = it.gender?.uppercase().orEmpty(),
isAgreedMarketingTerm = isTermMarketingSelected.value ?: false,
ci = it.uniqueKey.orEmpty(),
),
)
userRepository.setUserInfo(
Expand All @@ -133,6 +134,7 @@ class PhoneViewModel
viewModelScope.launch {
authRepository.postToSignUp(userRepository.getAccessToken(), request)
.onSuccess {
userRepository.setUserStatus(it.status)
_postSignUpState.value = UiState.Success(it.nickname)
}
.onFailure {
Expand Down
14 changes: 10 additions & 4 deletions feature/buy/src/main/java/co/orange/buy/info/BuyInfoActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ class BuyInfoActivity :
Triple(R.string.buy_info_msg_placed, R.string.buy_info_btn_fix, false)
}

OrderStatus.SHIPPING.name -> {
Triple(R.string.buy_info_msg_shipping, R.string.buy_info_btn_fix, true)
}

OrderStatus.COMPLETED.name -> {
Triple(R.string.buy_info_msg_completed, R.string.buy_info_btn_completed, false)
}
Expand All @@ -121,6 +117,16 @@ class BuyInfoActivity :
Triple(R.string.buy_info_msg_cancelled, R.string.buy_info_btn_cancelled, false)
}

in
listOf(
OrderStatus.SHIPPING.name,
OrderStatus.DELAYED_SHIPPING.name,
OrderStatus.WARNING.name,
),
-> {
Triple(R.string.buy_info_msg_shipping, R.string.buy_info_btn_fix, true)
}

else -> return
}
with(binding) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ class BuyProgressViewModel
viewModelScope.launch {
buyRepository.postToRequestOrder(
OrderRequestModel(
buyProgressData?.productId.orEmpty(),
orderId,
optionList,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class AlarmRequestActivity :
this,
intent.getStringExtra(EXTRA_ORDER_ID).orEmpty(),
)
finish()
}

private fun navigateToSellFinishedActivity() {
Expand All @@ -122,6 +123,7 @@ class AlarmRequestActivity :
intent.getStringExtra(EXTRA_PRODUCT_IMAGE).orEmpty(),
intent.getIntExtra(EXTRA_SALE_PRICE, 0),
)
finish()
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ class DetailViewModel
}
}

fun getUserLogined() = userRepository.getAccessToken().isNotEmpty()
fun getUserLogined() = userRepository.getUserRegistered()
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import co.orange.core.extension.setOnSingleClickListener
import co.orange.core.extension.setOverThousand
import co.orange.core.navigation.NavigationManager
import co.orange.main.databinding.BottomSheetOptionBinding
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import javax.inject.Inject
import co.orange.main.R as featureR

@AndroidEntryPoint
class OptionBottomSheet :
BaseBottomSheet<BottomSheetOptionBinding>(featureR.layout.bottom_sheet_option) {
@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class HomeViewModel
_itemLikeMinusState.value = UiState.Empty
}

fun getUserLogined() = userRepository.getAccessToken().isNotEmpty()
fun getUserLogined() = userRepository.getUserRegistered()

fun setDeviceToken(deviceToken: String) {
userRepository.setDeviceToken(deviceToken)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ class ProfileViewModel
}
}

fun getUserLogined() = userRepository.getAccessToken().isNotEmpty()
fun getUserLogined() = userRepository.getUserRegistered()
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,5 @@ class SearchViewModel
_itemLikeMinusState.value = UiState.Empty
}

fun getUserLogined() = userRepository.getAccessToken().isNotEmpty()
fun getUserLogined() = userRepository.getUserRegistered()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package co.orange.main.splash

import android.os.Bundle
import android.view.View
import android.view.WindowManager
import co.orange.core.R
import co.orange.core.base.BaseDialog
import co.orange.core.extension.setOnSingleClickListener
import co.orange.main.databinding.DialogServerCheckBinding
import co.orange.main.R as featureR

class ServerCheckDialog :
BaseDialog<DialogServerCheckBinding>(featureR.layout.dialog_server_check) {
override fun onStart() {
super.onStart()
dialog?.window?.apply {
setLayout(
WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT,
)
setBackgroundDrawableResource(R.color.transparent)
}
dialog?.apply {
setCancelable(false)
setCanceledOnTouchOutside(false)
}
}

override fun onViewCreated(
view: View,
savedInstanceState: Bundle?,
) {
super.onViewCreated(view, savedInstanceState)

initQuitBtnListener()
}

private fun initQuitBtnListener() {
binding.btnQuit.setOnSingleClickListener {
dismiss()
requireActivity().finish()
}
}
}
Loading
Loading