Skip to content
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
10 changes: 10 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/migrations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@ plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.20'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
}

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

android {
namespace 'org.sopt.dosopttemplate'
compileSdk 34

defaultConfig {
applicationId "org.sopt.dosopttemplate"
minSdk 28
targetSdk 33
targetSdk 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

buildConfigField "String", "AUTH_BASE_URL", properties["base.url"]
}

buildFeatures {
Expand All @@ -36,11 +33,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '11'
jvmTarget = '17'
}
}

Expand Down Expand Up @@ -73,4 +70,13 @@ dependencies {
implementation("com.squareup.okhttp3:logging-interceptor")

implementation("com.github.bumptech.glide:glide:4.16.0")

implementation "androidx.core:core-ktx:x.y.z"

implementation 'androidx.room:room-runtime:2.6.1'
kapt 'androidx.room:room-compiler:2.6.1'
implementation "androidx.room:room-ktx:2.6.1"

implementation 'com.google.dagger:hilt-android:2.50'
kapt 'com.google.dagger:hilt-compiler:2.50'
}
7 changes: 5 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:name=".presentation.MyApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
Expand All @@ -23,7 +24,8 @@

<activity
android:name=".presentation.login.LoginActivity"
android:exported="true">
android:exported="true"
android:windowSoftInputMode="adjustResize">

<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand All @@ -33,7 +35,8 @@
</activity>
<activity
android:name=".presentation.signup.SignUpActivity"
android:exported="false" />
android:exported="false"
android:windowSoftInputMode="adjustResize" />
</application>

</manifest>
20 changes: 0 additions & 20 deletions app/src/main/java/org/sopt/dosopttemplate/data/api/AuthService.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.sopt.dosopttemplate.data.local

import androidx.room.Database
import androidx.room.RoomDatabase
import org.sopt.dosopttemplate.data.local.dao.UserInfoDao
import org.sopt.dosopttemplate.data.local.entity.UserInfoEntity

@Database(entities = [UserInfoEntity::class], version = 1)
abstract class AppDatabase : RoomDatabase() {
abstract fun userInfoDao(): UserInfoDao
}
Copy link
Member

Choose a reason for hiding this comment

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

추가로 interface를 구현했기 때문에 RoomDataSource는 필요 없고 UserInfoDao로 바로 RoomDataSourceImpl이 가능 할것 같습니다! 어제 회의때 이야기 한 부분인데 이 부분은 저도 아직 잘 몰라서.. 함께 고민해봐요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이 부분에 대해서도 고민해봤는데 UserInfoDao 가 db 에 직접적으로 접근할 수 있기 때문에 RoomDataSource를 통해서 추상화를 해주어야 한다고 생각했습니다!

지금 같이 가벼운 로직에는 UserInfoDao 에서 바로 Impl로 연결해도 될 것 같긴 한데 dao의 구현을 숨겨 캡슐화 하기 위해서 저는 분리하긴 했습니다

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.sopt.dosopttemplate.data.local.dao

import androidx.room.Dao
import androidx.room.Entity
import androidx.room.Insert
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
import org.sopt.dosopttemplate.data.local.entity.UserInfoEntity

@Entity
@Dao
interface UserInfoDao {
@Insert
fun saveUserInfo(userInfoEntity: UserInfoEntity)

@Query("SELECT * FROM user_info LIMIT 1")
fun getUserInfo(): Flow<UserInfoEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.sopt.dosopttemplate.data.local.datasource

import kotlinx.coroutines.flow.Flow
import org.sopt.dosopttemplate.data.local.entity.UserInfoEntity

interface RoomDataSource {
fun saveUserInfo(userInfoEntity: UserInfoEntity)
fun getUserInfo(): Flow<UserInfoEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.sopt.dosopttemplate.data.local.datasourceimpl

import kotlinx.coroutines.flow.Flow
import org.sopt.dosopttemplate.data.local.dao.UserInfoDao
import org.sopt.dosopttemplate.data.local.datasource.RoomDataSource
import org.sopt.dosopttemplate.data.local.entity.UserInfoEntity
import javax.inject.Inject

class RoomDataSourceImpl @Inject constructor(
private val userInfoDao: UserInfoDao
) : RoomDataSource {
override fun saveUserInfo(userInfoEntity: UserInfoEntity) {
userInfoDao.saveUserInfo(userInfoEntity)
}

override fun getUserInfo(): Flow<UserInfoEntity> {
return userInfoDao.getUserInfo()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.sopt.dosopttemplate.data.local.entity

import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.coroutines.flow.Flow
import org.sopt.dosopttemplate.domain.model.UserInfo

@Entity(tableName = "user_info")
data class UserInfoEntity(
@PrimaryKey(autoGenerate = true)
val userNum: Long = 0,
val nickName: String,
val id: String,
val password: String,
val mbti: String,
) {
fun toUserInfo(): UserInfo {
return UserInfo(
nickName = this.nickName,
id = this.id,
password = this.password,
mbti = this.mbti
)
}
Comment on lines +17 to +24
Copy link
Member

Choose a reason for hiding this comment

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

map 함수는 전 dto내부에 선언하는데 웹소소 처럼
따로 디렉토리 만들기도 하더라구요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

�취향 차이인 듯 합니다! 제 생각엔 각각의 장단점이 있어서 컨벤션 맞춰서 진행하면 되지 않을까 하는 생각 ㅎㅎ ?

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.sopt.dosopttemplate.data.local.repositoryimpl

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import org.sopt.dosopttemplate.data.local.dao.UserInfoDao
import org.sopt.dosopttemplate.data.local.entity.UserInfoEntity
import org.sopt.dosopttemplate.domain.model.UserInfo
import org.sopt.dosopttemplate.domain.repository.UserInfoRepository
import javax.inject.Inject

class UserInfoRepositoryImpl @Inject constructor(
private val userDao: UserInfoDao
) : UserInfoRepository {

override fun saveUserInfo(userInfo: UserInfo) {
userDao.saveUserInfo(
userInfoEntity = UserInfoEntity(
id = userInfo.id,
password = userInfo.password,
nickName = userInfo.nickName,
mbti = userInfo.mbti
)
)
}

override fun getUserInfo(): Flow<UserInfo> {
return userDao.getUserInfo().map { userInfoEntity ->
userInfoEntity.toUserInfo()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
package org.sopt.dosopttemplate.data
package org.sopt.dosopttemplate.data.remote

import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import kotlinx.serialization.json.Json
import okhttp3.MediaType.Companion.toMediaType
import org.sopt.dosopttemplate.BuildConfig
import retrofit2.Retrofit

object ApiManager {
private const val BASE_URL = BuildConfig.AUTH_BASE_URL

val retrofit: Retrofit by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(Json.asConverterFactory("application/json".toMediaType()))
.build()
}

val retrofitTest: Retrofit by lazy {
Retrofit.Builder()
Expand All @@ -23,7 +14,5 @@ object ApiManager {
.build()
}

inline fun <reified T> create(): T = retrofit.create<T>(T::class.java)

inline fun <reified T> createTest(): T = retrofitTest.create<T>(T::class.java)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sopt.dosopttemplate.data.api
package org.sopt.dosopttemplate.data.remote.api

import org.sopt.dosopttemplate.data.model.response.ResponseUser
import org.sopt.dosopttemplate.data.remote.model.response.ResponseUser
import retrofit2.Response
import retrofit2.http.GET
import retrofit2.http.Query
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.dosopttemplate.data.model.request
package org.sopt.dosopttemplate.data.remote.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 org.sopt.dosopttemplate.data.model.request
package org.sopt.dosopttemplate.data.remote.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 org.sopt.dosopttemplate.data.model.response
package org.sopt.dosopttemplate.data.remote.model.response

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 org.sopt.dosopttemplate.data.model.response
package org.sopt.dosopttemplate.data.remote.model.response

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 org.sopt.dosopttemplate.data.model.response
package org.sopt.dosopttemplate.data.remote.model.response

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/org/sopt/dosopttemplate/di/DatabaseModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.sopt.dosopttemplate.di

import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import org.sopt.dosopttemplate.data.local.AppDatabase
import org.sopt.dosopttemplate.data.local.dao.UserInfoDao
import org.sopt.dosopttemplate.data.local.datasource.RoomDataSource
import org.sopt.dosopttemplate.data.local.datasourceimpl.RoomDataSourceImpl
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class DatabaseModule {

companion object {
@Singleton
@Provides
fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase {
return Room.databaseBuilder(context, AppDatabase::class.java, "user_info").build()
}

@Singleton
@Provides
fun provideRoomDataSource(impl: RoomDataSourceImpl): RoomDataSource {
return impl
}

@Singleton
@Provides
Copy link
Member

Choose a reason for hiding this comment

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

@singleton
얘도 싱글톤으로 가는 건 어떨까요?

fun provideUserInfoDao(appDatabase: AppDatabase): UserInfoDao {
return appDatabase.userInfoDao()
}
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/org/sopt/dosopttemplate/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.dosopttemplate.di

import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.dosopttemplate.data.local.repositoryimpl.UserInfoRepositoryImpl
import org.sopt.dosopttemplate.domain.repository.UserInfoRepository
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {
@Singleton
@Binds
abstract fun provideUserInfoRepositoryImpl(userInfoRepositoryImpl: UserInfoRepositoryImpl): UserInfoRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.dosopttemplate.domain.model

data class UserInfo(
val nickName: String,
val id: String,
val password: String,
val mbti: String,
)
Loading