Skip to content

Commit

Permalink
[Refactor/#165] 문의하기 리팩토링 (#189)
Browse files Browse the repository at this point in the history
* refactor: inquire

* add: todo
  • Loading branch information
HI-JIN2 authored May 22, 2024
1 parent cedc606 commit d372413
Show file tree
Hide file tree
Showing 17 changed files with 252 additions and 191 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

</activity>
<activity
android:name=".ui.mypage.inquire.InquireActivity"
android:name=".ui.mypage.inquire.InquiryActivity"
android:exported="false" />
<activity
android:name=".ui.review.write.ReviewWriteRateActivity"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.eatssu.android.data.dto.request

data class InquiriesRequest(
data class InquiryRequest(
val email: String,
val content: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.eatssu.android.data.repository

import com.eatssu.android.base.BaseResponse
import com.eatssu.android.data.dto.request.InquiryRequest
import kotlinx.coroutines.flow.Flow

interface InquiryRepository {
suspend fun postInquiry(
body: InquiryRequest,
): Flow<BaseResponse<Void>>

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.eatssu.android.data.repository

import com.eatssu.android.base.BaseResponse
import com.eatssu.android.data.dto.request.InquiryRequest
import com.eatssu.android.data.service.InquiryService
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import javax.inject.Inject

class InquiryRepositoryImpl @Inject constructor(private val inquiryService: InquiryService) :
InquiryRepository {

override suspend fun postInquiry(body: InquiryRequest): Flow<BaseResponse<Void>> =
flow {
emit(inquiryService.inquireContent(body))
}

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.eatssu.android.data.service

import com.eatssu.android.base.BaseResponse
import com.eatssu.android.data.dto.request.InquiryRequest
import retrofit2.http.Body
import retrofit2.http.POST

interface InquiryService {
@POST("inquiries/") // 문의 작성
suspend fun inquireContent(
@Body request: InquiryRequest,
): BaseResponse<Void>

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.eatssu.android.data.usecase

import com.eatssu.android.base.BaseResponse
import com.eatssu.android.data.dto.request.InquiryRequest
import com.eatssu.android.data.repository.InquiryRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class PostInquiryUseCase @Inject constructor(
private val inquiryRepository: InquiryRepository,
) {
suspend operator fun invoke(body: InquiryRequest): Flow<BaseResponse<Void>> =
inquiryRepository.postInquiry(body)

}
7 changes: 7 additions & 0 deletions app/src/main/java/com/eatssu/android/di/DataModule.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.eatssu.android.di


import com.eatssu.android.data.repository.InquiryRepository
import com.eatssu.android.data.repository.InquiryRepositoryImpl
import com.eatssu.android.data.repository.OauthRepository
import com.eatssu.android.data.repository.OauthRepositoryImpl
import com.eatssu.android.data.repository.UserRepository
Expand All @@ -24,4 +26,9 @@ abstract class DataModule {
userRepositoryImpl: UserRepositoryImpl,
): UserRepository

@Binds
internal abstract fun bindsInquiryRepository(
inquiryRepositoryImpl: InquiryRepositoryImpl,
): InquiryRepository

}
7 changes: 7 additions & 0 deletions app/src/main/java/com/eatssu/android/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.eatssu.android.di


import com.eatssu.android.BuildConfig
import com.eatssu.android.data.service.InquiryService
import com.eatssu.android.data.service.OauthService
import com.eatssu.android.data.service.UserService
import com.eatssu.android.di.network.TokenInterceptor
Expand Down Expand Up @@ -75,4 +76,10 @@ object NetworkModule {
fun provideUserService(retrofit: Retrofit): UserService {
return retrofit.create(UserService::class.java)
}

@Provides
@Singleton
fun provideInquiryService(retrofit: Retrofit): InquiryService {
return retrofit.create(InquiryService::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.eatssu.android.databinding.ActivityMyPageBinding
import com.eatssu.android.ui.common.VersionViewModel
import com.eatssu.android.ui.common.VersionViewModelFactory
import com.eatssu.android.ui.login.LoginActivity
import com.eatssu.android.ui.mypage.inquire.InquireActivity
import com.eatssu.android.ui.mypage.inquire.InquiryActivity
import com.eatssu.android.ui.mypage.myreview.MyReviewListActivity
import com.eatssu.android.ui.mypage.terms.WebViewActivity
import com.eatssu.android.ui.mypage.usernamechange.UserNameChangeActivity
Expand Down Expand Up @@ -64,7 +64,7 @@ class MyPageActivity : BaseActivity<ActivityMyPageBinding>(ActivityMyPageBinding
}

binding.llInquire.setOnClickListener {
startActivity<InquireActivity>()
startActivity<InquiryActivity>()
}

binding.llMyReview.setOnClickListener {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d372413

Please sign in to comment.