-
Notifications
You must be signed in to change notification settings - Fork 0
[PC-1614] Billing 모듈 의존성 리팩토링 #201
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
Changes from all commits
e1aa97b
4a37b82
2a9bcd7
7261d61
887112c
a88fe8b
5c3d7d1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package com.puzzle.billing.di | ||
|
|
||
| import com.puzzle.billing.data.BillingHelperImpl | ||
| import com.puzzle.billing.data.PaymentRepositoryImpl | ||
| import com.puzzle.billing.domain.BillingHelper | ||
| import com.puzzle.billing.domain.PaymentRepository | ||
| import com.puzzle.billing.network.source.payment.PaymentDataSource | ||
| import com.puzzle.billing.network.source.payment.PaymentDataSourceImpl | ||
| import dagger.Binds | ||
| import dagger.Module | ||
| import dagger.hilt.InstallIn | ||
| import dagger.hilt.components.SingletonComponent | ||
| import javax.inject.Singleton | ||
|
|
||
| @Module | ||
| @InstallIn(SingletonComponent::class) | ||
| abstract class BillingModule { | ||
| @Binds | ||
| @Singleton | ||
| abstract fun bindPaymentDataSource( | ||
| paymentDataSourceImpl: PaymentDataSourceImpl | ||
| ): PaymentDataSource | ||
|
|
||
| @Binds | ||
| @Singleton | ||
| abstract fun bindPaymentRepository( | ||
| paymentRepositoryImpl: PaymentRepositoryImpl | ||
| ): PaymentRepository | ||
|
|
||
| @Binds | ||
| @Singleton | ||
| abstract fun bindBillingHelper( | ||
| billingHelperImpl: BillingHelperImpl | ||
| ): BillingHelper | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,9 @@ | ||
| package com.puzzle.billing.domain | ||
|
|
||
| import com.puzzle.domain.model.payment.CashProduct | ||
| import com.puzzle.domain.model.payment.PurchaseProduct | ||
| import com.puzzle.domain.model.payment.VerifyPurchaseProduct | ||
| import com.puzzle.billing.model.CashProduct | ||
| import com.puzzle.billing.model.PurchaseProduct | ||
|
|
||
| interface PaymentRepository { | ||
| suspend fun getAvailableProduct(): CashProduct | ||
| suspend fun verifyPurchaseProduct(purchaseProduct: PurchaseProduct): VerifyPurchaseProduct | ||
| suspend fun verifyPurchaseProduct(purchaseProduct: PurchaseProduct): Int | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if VerifyPurchaseProduct exists in the billing module
echo "=== Searching for VerifyPurchaseProduct in billing module ==="
find core/billing -type f -name "*.kt" | xargs grep -l "VerifyPurchaseProduct" 2>/dev/null || echo "Not found in files"
# Search for definition of VerifyPurchaseProduct
echo -e "\n=== Searching for VerifyPurchaseProduct definition ==="
rg "class|data class|enum|sealed class|object|typealias.*VerifyPurchaseProduct" --type=kotlin
# Check the PaymentRepository file
echo -e "\n=== Content of PaymentRepository.kt ==="
find core/billing -name "PaymentRepository.kt" -type f -exec cat {} \;
# Search for usages of verifyPurchaseProduct method
echo -e "\n=== Finding callers of verifyPurchaseProduct ==="
rg -n "verifyPurchaseProduct" --type=kotlin -B2 -A2Repository: Piece-Puzzly/Piece-Android Length of output: 50382 🏁 Script executed: #!/bin/bash
# Get the PaymentRepository.kt file content
echo "=== PaymentRepository.kt content ==="
cat core/billing/src/main/java/com/puzzle/billing/domain/PaymentRepository.kt
echo -e "\n=== VerifyPurchaseProduct.kt content ==="
cat core/billing/src/main/java/com/puzzle/billing/model/payment/VerifyPurchaseProduct.kt
echo -e "\n=== Usages of verifyPurchaseProduct method ==="
rg "verifyPurchaseProduct" --type=kotlin -B3 -A3Repository: Piece-Puzzly/Piece-Android Length of output: 4815 🏁 Script executed: #!/bin/bash
# Get PaymentRepositoryImpl to see what toDomain() actually does
echo "=== PaymentRepositoryImpl.kt content ==="
cat core/billing/src/main/java/com/puzzle/billing/data/PaymentRepositoryImpl.kt
# Check for toDomain extension functions
echo -e "\n=== Searching for toDomain extension on VerifyPurchaseProductResponse ==="
rg "fun.*VerifyPurchaseProductResponse.*toDomain" --type=kotlin -A5
# Check ProductMapper which likely has the mapping logic
echo -e "\n=== ProductMapper.kt content ==="
cat core/billing/src/main/java/com/puzzle/billing/mapper/payment/ProductMapper.ktRepository: Piece-Puzzly/Piece-Android Length of output: 2542 Return type should be The domain model
The current mapper in 🤖 Prompt for AI Agents |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package com.puzzle.billing.mapper.payment | ||
|
|
||
| import com.puzzle.billing.model.CashProduct | ||
| import com.puzzle.billing.model.Product | ||
| import com.puzzle.network.model.UNKNOWN_INT | ||
| import com.puzzle.network.model.payment.BasicCashProductResponse | ||
| import com.puzzle.network.model.payment.GetAvailableProductResponse | ||
| import com.puzzle.network.model.payment.PromotionProductResponse | ||
| import com.puzzle.network.model.payment.VerifyPurchaseProductResponse | ||
| import java.math.BigDecimal | ||
|
|
||
| internal fun GetAvailableProductResponse.toDomain(): CashProduct = | ||
| CashProduct( | ||
| products = this.promotionCashProducts.map(PromotionProductResponse::toDomain) + | ||
| this.basicCashProducts.map(BasicCashProductResponse::toDomain), | ||
| ) | ||
|
|
||
| internal fun BasicCashProductResponse.toDomain(): Product.BasicCashProduct = | ||
| Product.BasicCashProduct( | ||
| uuid = this.uuid, | ||
| name = this.name, | ||
| rewardPuzzleCount = this.rewardPuzzleCount, | ||
| originalAmount = BigDecimal(this.originalAmount), | ||
| discountRate = this.discountRate, | ||
| discountedAmount = BigDecimal(this.discountedAmount), | ||
| ) | ||
|
|
||
| internal fun PromotionProductResponse.toDomain(): Product.PromotionProduct = | ||
| Product.PromotionProduct( | ||
| uuid = this.uuid, | ||
| imageUrl = this.cardImageUrl, | ||
| ) | ||
|
|
||
| internal fun VerifyPurchaseProductResponse.toDomain(): Int = this.rewardPuzzleCount ?: UNKNOWN_INT |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.puzzle.billing.model | ||
|
|
||
| import com.puzzle.network.model.payment.VerifyPurchaseProductRequest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Network layer dependency contradicts module independence goal. The import of Impact:
Recommendation: ♻️ Suggested refactor to remove network dependencyRemove the network import and toDto() method from this file: package com.puzzle.billing.model
-import com.puzzle.network.model.payment.VerifyPurchaseProductRequest
-
// api
data class PurchaseProduct(
val uuid: String,
val credential: String,
val store: Store = Store.PLAY_STORE,
-) {
- fun toDto() = VerifyPurchaseProductRequest(
- productUUID = uuid,
- purchaseCredential = credential,
- store = store.name,
- )
-}
+)
enum class Store {
PLAY_STORE, APP_STORE
}Then create a mapper in package com.puzzle.billing.mapper.payment
import com.puzzle.billing.model.PurchaseProduct
import com.puzzle.network.model.payment.VerifyPurchaseProductRequest
fun PurchaseProduct.toDto() = VerifyPurchaseProductRequest(
productUUID = uuid,
purchaseCredential = credential,
store = store.name,
)🤖 Prompt for AI Agents |
||
|
|
||
| // api | ||
| data class PurchaseProduct( | ||
| val uuid: String, | ||
| val credential: String, | ||
| val store: Store = Store.PLAY_STORE, | ||
| ) { | ||
| fun toDto() = VerifyPurchaseProductRequest( | ||
| productUUID = uuid, | ||
| purchaseCredential = credential, | ||
| store = store.name, | ||
| ) | ||
| } | ||
|
|
||
| enum class Store { | ||
| PLAY_STORE, APP_STORE | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
구매 검증 성공 시 로깅은 빼기로 정해졌나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IOS 는 추가를 일단안한거같기도하고, 정확한 price 가 아니고 퍼즐값이라 일단 제거했어요