Skip to content

Commit

Permalink
CheoCharm#72 refactor: local, remote 모듈을 data 모듈에 병합
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyesung82 committed Mar 16, 2024
1 parent f5ac2bf commit 4c37411
Show file tree
Hide file tree
Showing 53 changed files with 147 additions and 312 deletions.
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ dependencies {
implementation project(":presentation")
implementation project(":domain")
implementation project(":data")
implementation project(":remote")
implementation project(":local")

implementation "androidx.core:core-ktx:$coreKtxVersion"

Expand Down
52 changes: 46 additions & 6 deletions data/build.gradle
Original file line number Diff line number Diff line change
@@ -1,24 +1,64 @@
plugins {
id 'java-library'
id 'org.jetbrains.kotlin.jvm'
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
}

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
namespace = "com.cheocharm.data"

compileSdk 34

defaultConfig {
minSdk 23
targetSdk 34

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

buildConfigField "String", "BASE_URL", properties['base.url']
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = jvmTarget
}
}

dependencies {
implementation project(":domain")

def retrofitVersion = "2.9.0"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation "androidx.test.ext:junit:$junitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoCoreVersion"

// Hilt
implementation "com.google.dagger:hilt-core:$hiltVersion"
implementation "com.google.dagger:hilt-android:$hiltVersion"
kapt "com.google.dagger:hilt-android-compiler:$hiltVersion"

// kotlin coroutine
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutineVersion"

// paging - without Android dependencies
implementation "androidx.paging:paging-common-ktx:$pagingVersion"

// Retrofit
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.okhttp3:logging-interceptor:4.9.3"
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.local
package com.cheocharm.data

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package com.cheocharm.remote.di
package com.cheocharm.data.di

import com.cheocharm.data.remote.source.GroupRemoteDataSource
import com.cheocharm.remote.source.GroupRemoteDataSourceImpl
import com.cheocharm.data.local.source.AuthLocalDataSource
import com.cheocharm.data.local.source.AuthLocalDataSourceImpl
import com.cheocharm.data.remote.source.AuthRemoteDataSource
import com.cheocharm.data.remote.source.AuthRemoteDataSourceImpl
import com.cheocharm.data.remote.source.GroupRemoteDataSource
import com.cheocharm.data.remote.source.GroupRemoteDataSourceImpl
import com.cheocharm.data.remote.source.LoginRemoteDataSource
import com.cheocharm.data.remote.source.LoginRemoteDataSourceImpl
import com.cheocharm.data.remote.source.MyGroupsRemoteDataSource
import com.cheocharm.data.remote.source.MyGroupsRemoteDataSourceImpl
import com.cheocharm.data.remote.source.WriteRemoteDataSource
import com.cheocharm.remote.source.AuthRemoteDataSourceImpl
import com.cheocharm.remote.source.LoginRemoteDataSourceImpl
import com.cheocharm.remote.source.MyGroupsRemoteDataSourceImpl
import com.cheocharm.remote.source.WriteRemoteDataSourceImpl
import com.cheocharm.data.remote.source.WriteRemoteDataSourceImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand All @@ -19,6 +21,9 @@ import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal abstract class DataSourceModule {
@Binds
@Singleton
abstract fun bindAuthLocalDataSource(dataSourceImpl: AuthLocalDataSourceImpl): AuthLocalDataSource

@Binds
@Singleton
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cheocharm.remote.di
package com.cheocharm.data.di

import com.cheocharm.remote.BuildConfig
import com.cheocharm.data.BuildConfig
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.cheocharm.remote.di
package com.cheocharm.data.di

import com.cheocharm.remote.api.GroupApi
import com.cheocharm.remote.api.LoginApi
import com.cheocharm.remote.api.TokenApi
import com.cheocharm.remote.api.DiaryApi
import com.cheocharm.remote.network.AuthInterceptor
import com.cheocharm.data.remote.api.GroupApi
import com.cheocharm.data.remote.api.LoginApi
import com.cheocharm.data.remote.api.TokenApi
import com.cheocharm.data.remote.api.DiaryApi
import com.cheocharm.data.remote.network.AuthInterceptor
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cheocharm.local.di
package com.cheocharm.data.di

import com.cheocharm.local.SharedPrefManager
import com.cheocharm.local.SharedPrefManagerImpl
import com.cheocharm.data.local.SharedPrefManager
import com.cheocharm.data.local.SharedPrefManagerImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.local
package com.cheocharm.data.local

interface SharedPrefManager {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.local
package com.cheocharm.data.local

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.cheocharm.local.source
package com.cheocharm.data.local.source

import com.cheocharm.data.local.source.AuthLocalDataSource
import com.cheocharm.local.SharedPrefManager
import com.cheocharm.data.local.SharedPrefManager
import javax.inject.Inject

class AuthLocalDataSourceImpl @Inject constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.cheocharm.remote.api
package com.cheocharm.data.remote.api

import com.cheocharm.remote.model.BaseResponse
import com.cheocharm.remote.model.request.WriteDiaryDto
import com.cheocharm.remote.model.request.WriteImageDto
import com.cheocharm.remote.model.response.write.MyGroup
import com.cheocharm.remote.model.response.write.WriteDiaryResponse
import com.cheocharm.remote.model.response.write.WriteImageResponse
import com.cheocharm.data.remote.model.BaseResponse
import com.cheocharm.data.remote.model.request.WriteDiaryDto
import com.cheocharm.data.remote.model.request.WriteImageDto
import com.cheocharm.data.remote.model.response.write.MyGroup
import com.cheocharm.data.remote.model.response.write.WriteDiaryResponse
import com.cheocharm.data.remote.model.response.write.WriteImageResponse
import okhttp3.MultipartBody
import retrofit2.http.Body
import retrofit2.http.GET
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cheocharm.remote.api
package com.cheocharm.data.remote.api

import com.cheocharm.remote.model.BaseResponse
import com.cheocharm.remote.model.response.group.GroupSearchResponse
import com.cheocharm.data.remote.model.BaseResponse
import com.cheocharm.data.remote.model.response.group.GroupSearchResponse
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.cheocharm.remote.api
package com.cheocharm.data.remote.api

import com.cheocharm.remote.model.BaseResponse
import com.cheocharm.remote.model.TokenResponse
import com.cheocharm.remote.model.request.GoogleSignUpDto
import com.cheocharm.remote.model.request.MapZSignInDto
import com.cheocharm.remote.model.request.MapZSignUpDto
import com.cheocharm.data.remote.model.BaseResponse
import com.cheocharm.data.remote.model.TokenResponse
import com.cheocharm.data.remote.model.request.GoogleSignUpDto
import com.cheocharm.data.remote.model.request.MapZSignInDto
import com.cheocharm.data.remote.model.request.MapZSignUpDto
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.cheocharm.remote.api
package com.cheocharm.data.remote.api

import com.cheocharm.remote.model.BaseResponse
import com.cheocharm.remote.model.TokenResponse
import com.cheocharm.data.remote.model.BaseResponse
import com.cheocharm.data.remote.model.TokenResponse
import retrofit2.http.GET
import retrofit2.http.Header

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.cheocharm.remote.mapper
package com.cheocharm.data.remote.mapper

import com.cheocharm.domain.model.Group
import com.cheocharm.domain.model.GroupMember
import com.cheocharm.domain.model.GroupSearch
import com.cheocharm.remote.model.response.group.GroupSearchResponse
import com.cheocharm.data.remote.model.response.group.GroupSearchResponse

// remote -> domain
internal fun GroupSearchResponse.toDomain(): GroupSearch {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.cheocharm.remote.mapper
package com.cheocharm.data.remote.mapper

import com.cheocharm.domain.model.GoogleSignUpRequest
import com.cheocharm.domain.model.Token
import com.cheocharm.domain.model.MapZSignInRequest
import com.cheocharm.domain.model.MapZSignUpRequest
import com.cheocharm.remote.model.TokenResponse
import com.cheocharm.remote.model.request.GoogleSignUpDto
import com.cheocharm.remote.model.request.MapZSignInDto
import com.cheocharm.remote.model.request.MapZSignUpDto
import com.cheocharm.data.remote.model.TokenResponse
import com.cheocharm.data.remote.model.request.GoogleSignUpDto
import com.cheocharm.data.remote.model.request.MapZSignInDto
import com.cheocharm.data.remote.model.request.MapZSignUpDto

// domain -> remote
internal fun MapZSignUpRequest.toDto(): MapZSignUpDto {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.cheocharm.remote.mapper
package com.cheocharm.data.remote.mapper

import com.cheocharm.data.model.GroupData
import com.cheocharm.domain.model.TempDiary
import com.cheocharm.domain.model.WriteDiaryRequest
import com.cheocharm.domain.model.WriteImageRequest
import com.cheocharm.remote.model.request.WriteDiaryDto
import com.cheocharm.remote.model.request.WriteImageDto
import com.cheocharm.remote.model.response.write.MyGroup
import com.cheocharm.remote.model.response.write.WriteDiaryResponse
import com.cheocharm.remote.model.response.write.WriteImageResponse
import com.cheocharm.data.remote.model.request.WriteDiaryDto
import com.cheocharm.data.remote.model.request.WriteImageDto
import com.cheocharm.data.remote.model.response.write.MyGroup
import com.cheocharm.data.remote.model.response.write.WriteDiaryResponse
import com.cheocharm.data.remote.model.response.write.WriteImageResponse

internal fun MyGroup.toData(): GroupData {
return GroupData(groupName, groupImageUrl, count, listOf(chiefUserImage), groupId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model
package com.cheocharm.data.remote.model

data class BaseResponse<T>(
val statusCode: Int,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model
package com.cheocharm.data.remote.model

data class TokenResponse(
val accessToken: String?,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.request
package com.cheocharm.data.remote.model.request

data class GoogleSignUpDto(
val username: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.request
package com.cheocharm.data.remote.model.request

data class MapZSignInDto(
val email: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.request
package com.cheocharm.data.remote.model.request

data class MapZSignUpDto(
val email: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.request
package com.cheocharm.data.remote.model.request

data class WriteDiaryDto(
val diaryId: Long,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.request
package com.cheocharm.data.remote.model.request

data class WriteImageDto(
val groupId: Long,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.response.group
package com.cheocharm.data.remote.model.response.group

data class GroupResponse(
val groupName: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.cheocharm.data.remote.model.response.group

import com.cheocharm.data.remote.model.response.group.GroupResponse

data class GroupSearchResponse(
val hasNextPage: Boolean,
val groupList: List<GroupResponse>
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.model.response.write
package com.cheocharm.data.remote.model.response.write

data class MyGroup(
val groupName: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.cheocharm.data.remote.model.response.write

data class WriteDiaryResponse(val diaryId: Long)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.cheocharm.remote.model.response.write
package com.cheocharm.data.remote.model.response.write

data class WriteImageResponse(val diaryId: Long, val imageURLs: List<String>)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cheocharm.remote.network
package com.cheocharm.data.remote.network

import com.cheocharm.domain.repository.AuthRepository
import android.util.Log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.cheocharm.remote.source
package com.cheocharm.data.remote.source

import com.cheocharm.data.error.ErrorData
import com.cheocharm.data.remote.source.AuthRemoteDataSource
import com.cheocharm.domain.model.Token
import com.cheocharm.remote.api.TokenApi
import com.cheocharm.remote.mapper.toDomain
import com.cheocharm.data.remote.api.TokenApi
import com.cheocharm.data.remote.mapper.toDomain
import java.net.UnknownHostException
import javax.inject.Inject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package com.cheocharm.remote.source
package com.cheocharm.data.remote.source

import androidx.paging.Pager
import androidx.paging.PagingConfig
import androidx.paging.PagingData
import com.cheocharm.data.error.ErrorData
import com.cheocharm.data.remote.source.GroupRemoteDataSource
import com.cheocharm.domain.model.Group
import com.cheocharm.remote.api.GroupApi
import com.cheocharm.data.remote.api.GroupApi
import kotlinx.coroutines.flow.Flow
import java.net.UnknownHostException
import javax.inject.Inject
Expand Down
Loading

0 comments on commit 4c37411

Please sign in to comment.