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

[리팩토링] 과제 리팩토링 - 아키텍처 + 힐트 적용 #19

Open
wants to merge 6 commits into
base: develop-compose
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.9.0'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

Properties properties = new Properties()
Expand Down Expand Up @@ -82,4 +84,11 @@ dependencies {
// define any required OkHttp artifacts without version
implementation("com.squareup.okhttp3:okhttp")
implementation("com.squareup.okhttp3:logging-interceptor")

// hilt
implementation 'com.google.dagger:hilt-android:2.51'
kapt 'com.google.dagger:hilt-compiler:2.51.1'
implementation 'androidx.hilt:hilt-navigation-compose:1.2.0'

implementation("io.coil-kt:coil-compose:2.4.0")
}
16 changes: 8 additions & 8 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".NowSoptApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -16,7 +16,12 @@
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".LoginActivity"
android:name=".presentation.ui.login.LoginActivity"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid"></activity>
<activity
android:name=".presentation.ui.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid">
Expand All @@ -27,12 +32,7 @@
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid"></activity>
<activity
android:name=".SignupActivity"
android:name=".presentation.ui.signup.SignupActivity"
android:exported="false"
android:label="@string/app_name"
android:theme="@style/Theme.NOWSOPTAndroid"></activity>
Expand Down
52 changes: 0 additions & 52 deletions app/src/main/java/com/sopt/now/compose/HomeScreen.kt

This file was deleted.

42 changes: 0 additions & 42 deletions app/src/main/java/com/sopt/now/compose/HomeViewModel.kt

This file was deleted.

11 changes: 11 additions & 0 deletions app/src/main/java/com/sopt/now/compose/NowSoptApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.sopt.now.compose

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class NowSoptApplication: Application() {
override fun onCreate() {
super.onCreate()
}
}
6 changes: 0 additions & 6 deletions app/src/main/java/com/sopt/now/compose/SignupState.kt

This file was deleted.

57 changes: 0 additions & 57 deletions app/src/main/java/com/sopt/now/compose/SignupViewModel.kt

This file was deleted.

9 changes: 0 additions & 9 deletions app/src/main/java/com/sopt/now/compose/User.kt

This file was deleted.

4 changes: 3 additions & 1 deletion app/src/main/java/com/sopt/now/compose/data/ApiFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.sopt.now.compose.data
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.sopt.now.compose.BuildConfig.AUTH_BASE_URL
import com.sopt.now.compose.BuildConfig.USER_API_URL
import com.sopt.now.compose.data.service.AuthService
import com.sopt.now.compose.data.service.FriendService
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import retrofit2.Retrofit
Expand All @@ -19,5 +21,5 @@ object ApiFactory {

object ServicePool {
val authService = ApiFactory.create<AuthService, String>(AUTH_BASE_URL)
val userService = ApiFactory.create<AuthService, String>(USER_API_URL)
val friendService = ApiFactory.create<FriendService, String>(USER_API_URL)
}
28 changes: 0 additions & 28 deletions app/src/main/java/com/sopt/now/compose/data/AuthService.kt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sopt.now.compose.data.datasource

import com.sopt.now.compose.data.model.request.RequestLoginDto
import com.sopt.now.compose.data.model.request.RequestSignupDto
import com.sopt.now.compose.data.model.response.ResponseUserInfoDto
import com.sopt.now.compose.util.BaseResponse

interface AuthRemoteDataSource {
suspend fun signup(requestSignupDto: RequestSignupDto): BaseResponse<Unit>

suspend fun login(requestLoginDto: RequestLoginDto): String?

suspend fun getUserInfo(memberId: String): BaseResponse<ResponseUserInfoDto>
Comment on lines +12 to +13
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 BaseResponse까지!! 좋네용

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.sopt.now.compose.data.datasource

import com.sopt.now.compose.data.model.response.ResponseFriendsDto

interface FriendRemoteDataSource {
suspend fun getFriendsList(page: Int): ResponseFriendsDto
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.sopt.now.compose.data.datasourceImpl

import com.sopt.now.compose.data.ServicePool
import com.sopt.now.compose.data.datasource.AuthRemoteDataSource
import com.sopt.now.compose.data.model.request.RequestLoginDto
import com.sopt.now.compose.data.model.request.RequestSignupDto
import com.sopt.now.compose.data.model.response.ResponseUserInfoDto
import com.sopt.now.compose.util.BaseResponse

class AuthRemoteDatasourceImpl : AuthRemoteDataSource {
private val authService = ServicePool.authService
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

시간 된다면 여기도 힐트 넣어주면 좋을 것 같아요!!


override suspend fun signup(requestSignupDto: RequestSignupDto): BaseResponse<Unit> =
authService.signup(requestSignupDto)

override suspend fun login(requestLoginDto: RequestLoginDto): String? =
authService.login(requestLoginDto).headers()[LOCATION]

override suspend fun getUserInfo(memberId: String): BaseResponse<ResponseUserInfoDto> =
authService.getUserInfo(memberId = memberId)

companion object {
const val LOCATION = "location"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.sopt.now.compose.data.datasourceImpl

import com.sopt.now.compose.data.datasource.FriendRemoteDataSource
import com.sopt.now.compose.data.model.response.ResponseFriendsDto
import com.sopt.now.compose.data.service.FriendService
import javax.inject.Inject

class FriendRemoteDatasourceImpl @Inject constructor(
private val friendService: FriendService
) : FriendRemoteDataSource {
override suspend fun getFriendsList(page: Int): ResponseFriendsDto =
friendService.getFriendsList(page = page)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.compose.data.DTO.request
package com.sopt.now.compose.data.model.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sopt.now.compose.data.DTO.request
package com.sopt.now.compose.data.model.request

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
Loading