Skip to content

Commit

Permalink
Merge pull request #46 from meongmory/feature/login_phone
Browse files Browse the repository at this point in the history
[feature/login_phone] 인증번호 화면 구현 및 api 연결
  • Loading branch information
SsongSik authored Aug 20, 2023
2 parents b1580bc + f39b7c0 commit 9ed4986
Show file tree
Hide file tree
Showing 34 changed files with 610 additions and 193 deletions.
5 changes: 0 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
android:label="@string/app_name"
android:theme="@style/Theme.Meongmory">

<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.meongmoryteam.presentation.ui.splash.SplashActivity"
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/com/meongmoryteam/meongmory/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.meongmoryteam.meongmory.di

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.meongmoryteam.data.service.ExampleApi
import com.meongmoryteam.data.service.login.LoginApi
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import java.util.concurrent.TimeUnit
import javax.inject.Singleton
Expand All @@ -19,14 +20,19 @@ object NetworkModule {
private val contentType = "application/json".toMediaType()
private val json = Json { ignoreUnknownKeys = true }

private const val BASE_URL = "https://www.test.com/"
private const val BASE_URL = "http://52.79.149.29/"

@Provides
@Singleton
fun provideClient(): OkHttpClient {
val loggingInterceptor = HttpLoggingInterceptor().apply {
level = HttpLoggingInterceptor.Level.BODY
}

return OkHttpClient.Builder()
.connectTimeout(100, TimeUnit.SECONDS)
.readTimeout(100, TimeUnit.SECONDS)
.addInterceptor(loggingInterceptor) // 인터셉터 추가
.build()
}

Expand All @@ -42,7 +48,7 @@ object NetworkModule {

@Provides
@Singleton
fun provideApi(retrofit: Retrofit): ExampleApi {
return retrofit.create(ExampleApi::class.java)
fun provideLoginApi(retrofit: Retrofit): LoginApi {
return retrofit.create(LoginApi::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.meongmoryteam.meongmory.di

import com.meongmoryteam.data.datasource.FoodDataSource
import com.meongmoryteam.data.datasource.FoodDataSourceImpl
import com.meongmoryteam.data.repository.FoodRepositoryImpl
import com.meongmoryteam.domain.repository.FoodRepository
import com.meongmoryteam.data.datasource.login.LoginDataSource
import com.meongmoryteam.data.datasource.login.LoginDataSourceImpl
import com.meongmoryteam.data.repository.login.LoginRepositoryImpl
import com.meongmoryteam.domain.repository.login.LoginRepository
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -16,13 +16,13 @@ abstract class RepositoryModule {

@Singleton
@Binds
abstract fun bindFoodRepository(
foodRepositoryImpl: FoodRepositoryImpl,
) : FoodRepository
abstract fun bindLoginRepository(
loginRepositoryImpl: LoginRepositoryImpl
): LoginRepository

@Singleton
@Binds
abstract fun bindFoodV2DataSource(
foodDataSourceImpl: FoodDataSourceImpl
): FoodDataSource
abstract fun bindLoginDataSource(
loginDataSourceImpl: LoginDataSourceImpl
): LoginDataSource
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.meongmoryteam.data.datasource.login

import com.meongmoryteam.data.model.response.login.GetSmsSendResponse
import com.meongmoryteam.data.model.request.login.SmsSendRequest
import com.meongmoryteam.data.model.request.login.SmsValidateRequest
import com.meongmoryteam.data.model.response.login.PostSmsValidateResponse

interface LoginDataSource {
suspend fun getSmsSend(smsSendRequest: SmsSendRequest): Result<GetSmsSendResponse>
suspend fun postSmsValidate(smsValidateRequest: SmsValidateRequest): Result<PostSmsValidateResponse>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.meongmoryteam.data.datasource.login

import com.meongmoryteam.data.model.response.login.GetSmsSendResponse
import com.meongmoryteam.data.model.request.login.SmsSendRequest
import com.meongmoryteam.data.model.request.login.SmsValidateRequest
import com.meongmoryteam.data.model.response.login.PostSmsValidateResponse
import com.meongmoryteam.data.service.login.LoginApi
import javax.inject.Inject

class LoginDataSourceImpl @Inject constructor(
private val loginApi: LoginApi
): LoginDataSource {

override suspend fun getSmsSend(smsSendRequest: SmsSendRequest): Result<GetSmsSendResponse> {
return runCatching { loginApi.getSmsSend(smsSendRequest) }
}

override suspend fun postSmsValidate(smsValidateRequest: SmsValidateRequest): Result<PostSmsValidateResponse> {
return runCatching { loginApi.postSmsValidate(smsValidateRequest) }
}
}
44 changes: 0 additions & 44 deletions data/src/main/java/com/meongmoryteam/data/model/GetWeekFood.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.meongmoryteam.data.model.request.login

import com.meongmoryteam.domain.model.reqeust.login.SmsSendRequestEntity
import kotlinx.serialization.Serializable

@Serializable
data class SmsSendRequest(
val phone: String
)

fun SmsSendRequestEntity.toSmsSendRequest(): SmsSendRequest {
return SmsSendRequest(
phone = this.phone
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.meongmoryteam.data.model.request.login

import com.meongmoryteam.domain.model.reqeust.login.SmsValidateRequestEntity
import kotlinx.serialization.Serializable

@Serializable
data class SmsValidateRequest(
val code: String,
val phone: String
)

fun SmsValidateRequestEntity.toSmsValidateRequest(): SmsValidateRequest {
return SmsValidateRequest(
code = this.code,
phone = this.phone
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.meongmoryteam.data.model.response.login

import com.meongmoryteam.domain.model.response.login.GetSmsSendData
import com.meongmoryteam.domain.model.response.login.GetSmsSendEntity
import kotlinx.serialization.Serializable

@Serializable
data class GetSmsSendResponse(
val status: Int,
val code: String,
val message: String,
val data: Data,
)

@Serializable
data class Data(
val value: String,
val message: String?
)

fun GetSmsSendResponse.toGetSmsSendEntity(): GetSmsSendEntity {
return GetSmsSendEntity(
status = this.status,
code = this.code,
message = this.message,
getSmsSendData = GetSmsSendData(
value = this.data.value,
message = this.data.message
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.meongmoryteam.data.model.response.login

import com.meongmoryteam.domain.model.response.login.PostSmsValidateEntity
import kotlinx.serialization.Serializable

@Serializable
data class PostSmsValidateResponse(
val status: Int,
val code: String,
val message: String,
val data: Boolean
)

fun PostSmsValidateResponse.toPostSmsValidateEntity(): PostSmsValidateEntity {
return PostSmsValidateEntity(
status = this.status,
code = this.code,
message = this.message,
data = this.data
)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.meongmoryteam.data.repository.login

import com.meongmoryteam.data.datasource.login.LoginDataSource
import com.meongmoryteam.data.model.response.login.toGetSmsSendEntity
import com.meongmoryteam.data.model.request.login.toSmsSendRequest
import com.meongmoryteam.data.model.request.login.toSmsValidateRequest
import com.meongmoryteam.data.model.response.login.toPostSmsValidateEntity
import com.meongmoryteam.domain.model.response.login.GetSmsSendEntity
import com.meongmoryteam.domain.model.reqeust.login.SmsSendRequestEntity
import com.meongmoryteam.domain.model.reqeust.login.SmsValidateRequestEntity
import com.meongmoryteam.domain.model.response.login.PostSmsValidateEntity
import com.meongmoryteam.domain.repository.login.LoginRepository
import javax.inject.Inject

class LoginRepositoryImpl @Inject constructor(
private val loginDataSource: LoginDataSource
) : LoginRepository {

override suspend fun getSmsSend(smsSendRequestEntity: SmsSendRequestEntity): Result<GetSmsSendEntity> {
return loginDataSource.getSmsSend(smsSendRequestEntity.toSmsSendRequest()).map { it.toGetSmsSendEntity() }
}

override suspend fun postSmsValidate(smsValidateRequestEntity: SmsValidateRequestEntity): Result<PostSmsValidateEntity> {
return loginDataSource.postSmsValidate(smsValidateRequestEntity.toSmsValidateRequest()).map { it.toPostSmsValidateEntity() }
}
}
13 changes: 0 additions & 13 deletions data/src/main/java/com/meongmoryteam/data/service/ExampleApi.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.meongmoryteam.data.service.login

import com.meongmoryteam.data.model.response.login.GetSmsSendResponse
import com.meongmoryteam.data.model.request.login.SmsSendRequest
import com.meongmoryteam.data.model.request.login.SmsValidateRequest
import com.meongmoryteam.data.model.response.login.PostSmsValidateResponse
import retrofit2.http.Body
import retrofit2.http.POST

interface LoginApi {

@POST("sms/send")
suspend fun getSmsSend(
@Body smsSendRequest: SmsSendRequest
): GetSmsSendResponse

@POST("sms/validate")
suspend fun postSmsValidate(
@Body smsValidateRequest: SmsValidateRequest
): PostSmsValidateResponse
}

This file was deleted.

Loading

0 comments on commit 9ed4986

Please sign in to comment.