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

쇼핑몰 바로가기 기능 네이버 스토어 추가 #244

Merged
merged 21 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1960acb
feat: 쇼핑몰 바로가기 기능 네이버 추가
ootr47 Jan 27, 2024
c58c0a1
fix: 11번가 쇼핑몰 이동 딥링크 변경
Taewan-P Jan 31, 2024
f953d5f
fix: 기본 VIEW 인텐트 처리할 브라우저가 존재하지 않을때 오류 수정
Taewan-P Jan 31, 2024
c518fae
feat: 쇼핑몰에 따른 로고 설정 추가, 네이버 로고 추가
ootr47 Jan 31, 2024
e742a93
fix: 네이버 로고 수정
Taewan-P Jan 31, 2024
350e639
Merge branch 'dev/and' into feat/and/go-to-naver-shop
Taewan-P Feb 5, 2024
23df5da
feat: 쇼핑몰 추가에 따른 api 및 코드 변경
ootr47 Feb 5, 2024
c13e5ab
Merge branch 'feat/and/go-to-naver-shop' of https://github.com/boostc…
ootr47 Feb 5, 2024
ac58979
refactor: 안드로이드 종속성 라이브러리 업데이트
Taewan-P Feb 5, 2024
6fee319
refactor: 차트 라이브러리 업데이트
Taewan-P Feb 5, 2024
7e2ced5
feat: 상품 검증 API 버전 변경
Taewan-P Feb 5, 2024
7670290
feat: 네이버 스마트스토어 딥링크 지원
Taewan-P Feb 5, 2024
9c169e8
feat: 네이버 스마트스토어 공유 링크 지원
Taewan-P Feb 5, 2024
5fca474
feat: 푸쉬알람 샵 정보 추가
EunhoKang Feb 5, 2024
848019d
feat: 데이터 이름 변경
EunhoKang Feb 5, 2024
190c616
feat: 푸시알림 on/off 요청 시 쇼핑몰 정보 추가
ootr47 Feb 5, 2024
f2d1a77
refactor: 변수 이름 변경
EunhoKang Feb 5, 2024
51c55b2
fix: DiffUtil 기준에 쇼핑몰 데이터 포함
EunhoKang Feb 5, 2024
951f95b
fix: 잘못된 초기화 체크 수정
ootr47 Feb 5, 2024
07ad7ae
refactor: 불필요한 로그 삭제
Taewan-P Feb 5, 2024
9b04600
fix: 사용되지 않는 import문 삭제
EunhoKang Feb 5, 2024
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
12 changes: 6 additions & 6 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ dependencies {
// Android
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.appcompat:appcompat:1.6.1")
implementation("com.google.android.material:material:1.10.0")
implementation("androidx.activity:activity-ktx:1.8.1")
implementation("com.google.android.material:material:1.11.0")
implementation("androidx.activity:activity-ktx:1.8.2")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.5")
implementation("androidx.navigation:navigation-ui-ktx:2.7.5")
implementation("androidx.navigation:navigation-fragment-ktx:2.7.6")
implementation("androidx.navigation:navigation-ui-ktx:2.7.6")

// Retrofit, Serialization
implementation("com.squareup.retrofit2:retrofit:2.9.0")
Expand All @@ -92,7 +92,7 @@ dependencies {
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

// Navigation
val navVersion = "2.7.5"
val navVersion = "2.7.6"
implementation("androidx.navigation:navigation-fragment-ktx:$navVersion")
implementation("androidx.navigation:navigation-ui-ktx:$navVersion")

Expand All @@ -111,7 +111,7 @@ dependencies {
kapt("androidx.hilt:hilt-compiler:1.1.0")

// Material chart
implementation("app.priceguard:materialchart:0.2.1")
implementation("app.priceguard:materialchart:0.2.2")
}

kapt {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable

@Serializable
data class ProductAddRequest(
val shop: String,
val productCode: String,
val targetPrice: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable

@Serializable
data class PricePatchRequest(
val shop: String,
val productCode: String,
val targetPrice: Int
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,39 +21,42 @@ import retrofit2.http.Path

interface ProductAPI {

@POST("verify")
@POST("v1/product/verify")
suspend fun verifyLink(
@Body productUrl: ProductVerifyRequest
): Response<ProductVerifyResponse>

@POST(".")
@POST("v1/product")
suspend fun addProduct(
@Body productAddRequest: ProductAddRequest
): Response<ProductAddResponse>

@GET("tracking")
@GET("product/tracking")
suspend fun getProductList(): Response<ProductListResponse>

@GET("recommend")
@GET("product/recommend")
suspend fun getRecommendedProductList(): Response<RecommendProductResponse>

@GET("{productCode}")
@GET("v1/product/{shop}/{productCode}")
suspend fun getProductDetail(
@Path("shop") shop: String,
@Path("productCode") productCode: String
): Response<ProductResponse>

@DELETE("{productCode}")
@DELETE("v1/product/{shop}/{productCode}")
suspend fun deleteProduct(
@Path("shop") shop: String,
@Path("productCode") productCode: String
): Response<ProductDeleteResponse>

@PATCH("targetPrice")
@PATCH("v1/product/targetPrice")
suspend fun updateTargetPrice(
@Body pricePatchRequest: PricePatchRequest
): Response<PricePatchResponse>

@PATCH("alert/{productCode}")
@PATCH("v1/product/alert/{shop}/{productCode}")
suspend fun updateAlert(
@Path("shop") shop: String,
@Path("productCode") productCode: String
): Response<AlertUpdateResponse>
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ interface ProductRepository {

suspend fun verifyLink(productUrl: String, isRenewed: Boolean = false): RepositoryResult<ProductVerifyResult, ProductErrorState>

suspend fun addProduct(productCode: String, targetPrice: Int, isRenewed: Boolean = false): RepositoryResult<ProductAddResult, ProductErrorState>
suspend fun addProduct(shop: String, productCode: String, targetPrice: Int, isRenewed: Boolean = false): RepositoryResult<ProductAddResult, ProductErrorState>

suspend fun getProductList(isRenewed: Boolean = false): RepositoryResult<List<ProductData>, ProductErrorState>

suspend fun getRecommendedProductList(isRenewed: Boolean = false): RepositoryResult<List<RecommendProductData>, ProductErrorState>

suspend fun getProductDetail(productCode: String, isRenewed: Boolean = false): RepositoryResult<ProductDetailResult, ProductErrorState>
suspend fun getProductDetail(shop: String, productCode: String, isRenewed: Boolean = false): RepositoryResult<ProductDetailResult, ProductErrorState>

suspend fun deleteProduct(productCode: String, isRenewed: Boolean = false): RepositoryResult<Boolean, ProductErrorState>
suspend fun deleteProduct(shop: String, productCode: String, isRenewed: Boolean = false): RepositoryResult<Boolean, ProductErrorState>

suspend fun updateTargetPrice(productCode: String, targetPrice: Int, isRenewed: Boolean = false): RepositoryResult<PricePatchResult, ProductErrorState>
suspend fun updateTargetPrice(shop: String, productCode: String, targetPrice: Int, isRenewed: Boolean = false): RepositoryResult<PricePatchResult, ProductErrorState>

suspend fun switchAlert(productCode: String, isRenewed: Boolean = false): RepositoryResult<Boolean, ProductErrorState>
suspend fun switchAlert(shop: String, productCode: String, isRenewed: Boolean = false): RepositoryResult<Boolean, ProductErrorState>
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,13 @@ class ProductRepositoryImpl @Inject constructor(
}

override suspend fun addProduct(
shop: String,
productCode: String,
targetPrice: Int,
isRenewed: Boolean
): RepositoryResult<ProductAddResult, ProductErrorState> {
val response = getApiResult {
productAPI.addProduct(ProductAddRequest(productCode, targetPrice))
productAPI.addProduct(ProductAddRequest(shop, productCode, targetPrice))
}
return when (response) {
is APIResult.Success -> {
Expand All @@ -124,7 +125,7 @@ class ProductRepositoryImpl @Inject constructor(

is APIResult.Error -> {
handleError(response.code, isRenewed) {
addProduct(productCode, targetPrice, true)
addProduct(shop, productCode, targetPrice, true)
}
}
}
Expand Down Expand Up @@ -190,11 +191,12 @@ class ProductRepositoryImpl @Inject constructor(
}

override suspend fun getProductDetail(
shop: String,
productCode: String,
isRenewed: Boolean
): RepositoryResult<ProductDetailResult, ProductErrorState> {
val response = getApiResult {
productAPI.getProductDetail(productCode)
productAPI.getProductDetail(shop, productCode)
}
return when (response) {
is APIResult.Success -> {
Expand All @@ -216,36 +218,38 @@ class ProductRepositoryImpl @Inject constructor(

is APIResult.Error -> {
handleError(response.code, isRenewed) {
getProductDetail(productCode, true)
getProductDetail(shop, productCode, true)
}
}
}
}

override suspend fun deleteProduct(
shop: String,
productCode: String,
isRenewed: Boolean
): RepositoryResult<Boolean, ProductErrorState> {
return when (val response = getApiResult { productAPI.deleteProduct(productCode) }) {
return when (val response = getApiResult { productAPI.deleteProduct(shop, productCode) }) {
is APIResult.Success -> {
RepositoryResult.Success(true)
}

is APIResult.Error -> {
handleError(response.code, isRenewed) {
deleteProduct(productCode, true)
deleteProduct(shop, productCode, true)
}
}
}
}

override suspend fun updateTargetPrice(
shop: String,
productCode: String,
targetPrice: Int,
isRenewed: Boolean
): RepositoryResult<PricePatchResult, ProductErrorState> {
val response = getApiResult {
productAPI.updateTargetPrice(PricePatchRequest(productCode, targetPrice))
productAPI.updateTargetPrice(PricePatchRequest(shop, productCode, targetPrice))
}
return when (response) {
is APIResult.Success -> {
Expand All @@ -259,21 +263,21 @@ class ProductRepositoryImpl @Inject constructor(

is APIResult.Error -> {
handleError(response.code, isRenewed) {
updateTargetPrice(productCode, targetPrice, true)
updateTargetPrice(shop, productCode, targetPrice, true)
}
}
}
}

override suspend fun switchAlert(productCode: String, isRenewed: Boolean): RepositoryResult<Boolean, ProductErrorState> {
return when (val response = getApiResult { productAPI.updateAlert(productCode) }) {
override suspend fun switchAlert(shop: String, productCode: String, isRenewed: Boolean): RepositoryResult<Boolean, ProductErrorState> {
return when (val response = getApiResult { productAPI.updateAlert(shop, productCode) }) {
is APIResult.Success -> {
RepositoryResult.Success(true)
}

is APIResult.Error -> {
handleError(response.code, isRenewed) {
deleteProduct(productCode, true)
deleteProduct(shop, productCode, true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object NetworkModule {
.build()

return Retrofit.Builder()
.baseUrl("${BASE_URL}/product/")
.baseUrl("${BASE_URL}/")
.addConverterFactory(json.asConverterFactory(MediaType.parse("application/json")!!))
.client(interceptorClient)
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ class PriceGuardFirebaseMessagingService : FirebaseMessagingService() {
it.title ?: return,
it.body ?: return,
it.imageUrl ?: return,
message.data["shop"] ?: return,
message.data["productCode"] ?: return
)
}
}

private fun sendNotification(title: String, body: String, imageUrl: Uri, data: String) {
private fun sendNotification(title: String, body: String, imageUrl: Uri, shop: String, code: String) {
val intent = Intent(this, DetailActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
intent.putExtra("productCode", data)
intent.putExtra("productShop", shop)
intent.putExtra("productCode", code)
intent.putExtra("directed", true)

val requestCode = getRequestCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class UpdateAlarmWorker @AssistedInject constructor(
) : CoroutineWorker(appContext, workerParams) {

override suspend fun doWork(): Result {
val inputData = inputData.getString(ARGUMENT_KEY) ?: return Result.failure()
val productShop = inputData.getString(PRODUCT_SHOP) ?: return Result.failure()
val productCode = inputData.getString(PRODUCT_CODE) ?: return Result.failure()

return updateAlarm(inputData)
return updateAlarm(productShop, productCode)
}

private suspend fun updateAlarm(productCode: String): Result {
private suspend fun updateAlarm(productShop: String, productCode: String): Result {
return try {
when (productRepository.switchAlert(productCode)) {
when (productRepository.switchAlert(productShop, productCode)) {
is RepositoryResult.Error -> {
Result.failure()
}
Expand All @@ -45,9 +46,14 @@ class UpdateAlarmWorker @AssistedInject constructor(
}

companion object {
const val ARGUMENT_KEY = "productCode"
fun createWorkRequest(inputString: String): OneTimeWorkRequest {
val inputData = Data.Builder().putString(ARGUMENT_KEY, inputString).build()
const val PRODUCT_CODE = "productCode"
const val PRODUCT_SHOP = "productShop"

fun createWorkRequest(inputString: Pair<String, String>): OneTimeWorkRequest {
val inputData = Data.Builder()
.putString(PRODUCT_SHOP, inputString.first)
.putString(PRODUCT_CODE, inputString.second)
.build()
val constraints = Constraints.Builder().build()
return OneTimeWorkRequestBuilder<UpdateAlarmWorker>()
.setInputData(inputData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ class AddItemActivity : AppCompatActivity() {
bundle.putString("link", data)
navController.navigate(R.id.registerItemLinkFragment, bundle)
}
} else if (intent.hasExtra("productCode") &&
} else if (intent.hasExtra("productShop") &&
intent.hasExtra("productCode") &&
intent.hasExtra("productTitle") &&
intent.hasExtra("productPrice") &&
intent.hasExtra("isAdding")
) {
val action =
RegisterItemLinkFragmentDirections.actionRegisterItemLinkFragmentToSetTargetPriceFragment(
intent.getStringExtra("productShop") ?: "",
intent.getStringExtra("productCode") ?: "",
intent.getStringExtra("productTitle") ?: "",
intent.getIntExtra("productPrice", 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class ConfirmItemLinkFragment : Fragment() {

private var _binding: FragmentConfirmItemLinkBinding? = null

Check failure on line 15 in android/app/src/main/java/app/priceguard/ui/additem/confirm/ConfirmItemLinkFragment.kt

View workflow job for this annotation

GitHub Actions / Check Kotlin Format

[ktlint] reported by reviewdog 🐶 Backing property name is only allowed when a matching public property or function exists Raw Output: android/app/src/main/java/app/priceguard/ui/additem/confirm/ConfirmItemLinkFragment.kt:15:17: error: Backing property name is only allowed when a matching public property or function exists (standard:property-naming)
private val binding get() = _binding!!
private val confirmItemLinkViewModel: ConfirmItemLinkViewModel by viewModels()

Expand Down Expand Up @@ -54,6 +54,7 @@
btnConfirmItemNext.setOnClickListener {
val action =
ConfirmItemLinkFragmentDirections.actionConfirmItemLinkFragmentToSetTargetPriceFragment(
arguments.getString("productShop") ?: "",
arguments.getString("productCode") ?: "",
arguments.getString("productName") ?: "",
arguments.getInt("productPrice"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Inject
lateinit var tokenRepository: TokenRepository

private var _binding: FragmentRegisterItemLinkBinding? = null

Check failure on line 29 in android/app/src/main/java/app/priceguard/ui/additem/link/RegisterItemLinkFragment.kt

View workflow job for this annotation

GitHub Actions / Check Kotlin Format

[ktlint] reported by reviewdog 🐶 Backing property name is only allowed when a matching public property or function exists Raw Output: android/app/src/main/java/app/priceguard/ui/additem/link/RegisterItemLinkFragment.kt:29:17: error: Backing property name is only allowed when a matching public property or function exists (standard:property-naming)
private val binding get() = _binding!!
private val registerItemLinkViewModel: RegisterItemLinkViewModel by viewModels()

Expand Down Expand Up @@ -98,6 +98,7 @@
is RegisterItemLinkViewModel.RegisterLinkEvent.SuccessVerification -> {
val action =
RegisterItemLinkFragmentDirections.actionRegisterItemLinkFragmentToConfirmItemLinkFragment(
event.product.shop,
event.product.productCode,
event.product.productPrice,
event.product.shop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
@Inject
lateinit var tokenRepository: TokenRepository

private var _binding: FragmentSetTargetPriceBinding? = null

Check failure on line 31 in android/app/src/main/java/app/priceguard/ui/additem/setprice/SetTargetPriceFragment.kt

View workflow job for this annotation

GitHub Actions / Check Kotlin Format

[ktlint] reported by reviewdog 🐶 Backing property name is only allowed when a matching public property or function exists Raw Output: android/app/src/main/java/app/priceguard/ui/additem/setprice/SetTargetPriceFragment.kt:31:17: error: Backing property name is only allowed when a matching public property or function exists (standard:property-naming)
private val binding get() = _binding!!
private val setTargetPriceViewModel: SetTargetPriceViewModel by viewModels()

Expand Down Expand Up @@ -67,12 +67,13 @@
private fun FragmentSetTargetPriceBinding.initView() {
val arguments = requireArguments()

val productShop = arguments.getString("productShop") ?: ""
val productCode = arguments.getString("productCode") ?: ""
val title = arguments.getString("productTitle") ?: ""
val price = arguments.getInt("productPrice")
val targetPrice = arguments.getInt("productTargetPrice")

setTargetPriceViewModel.setProductInfo(productCode, title, price, targetPrice)
setTargetPriceViewModel.setProductInfo(productShop, productCode, title, price, targetPrice)

tvSetPriceCurrentPrice.text =
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SetTargetPriceViewModel @Inject constructor(private val productRepository:
ViewModel() {

data class SetTargetPriceState(
val productShop: String = "",
val productCode: String = "",
val targetPrice: Int = 0,
val productName: String = "",
Expand All @@ -43,6 +44,7 @@ class SetTargetPriceViewModel @Inject constructor(private val productRepository:
viewModelScope.launch {
_state.value = state.value.copy(isReady = false)
val response = productRepository.addProduct(
_state.value.productShop,
_state.value.productCode,
_state.value.targetPrice
)
Expand All @@ -63,6 +65,7 @@ class SetTargetPriceViewModel @Inject constructor(private val productRepository:
viewModelScope.launch {
_state.value = state.value.copy(isReady = false)
val response = productRepository.updateTargetPrice(
_state.value.productShop,
_state.value.productCode,
_state.value.targetPrice
)
Expand All @@ -89,9 +92,10 @@ class SetTargetPriceViewModel @Inject constructor(private val productRepository:
)
}

fun setProductInfo(productCode: String, name: String, price: Int, targetPrice: Int) {
fun setProductInfo(productShop: String, productCode: String, name: String, price: Int, targetPrice: Int) {
_state.value =
state.value.copy(
productShop = productShop,
productCode = productCode,
productName = name,
productPrice = price,
Expand Down
Loading
Loading