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

[Week6] 6주차 필수 과제 #14

Open
wants to merge 26 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0ebb8fc
chore #13: move component to presentation layer
hyeeum Dec 4, 2024
f512b35
add #13: add core package
hyeeum Dec 4, 2024
1248207
chore #13: add Route and edit navigation package
hyeeum Dec 4, 2024
0f51c4f
chore #13: divide component to each package
hyeeum Dec 4, 2024
0a6499f
feature #13: MyUseCase
hyeeum Dec 6, 2024
13738ee
chore #13: apply MyUseCase
hyeeum Dec 6, 2024
e8cc88b
feature #13: SignInUseCase
hyeeum Dec 6, 2024
e4170ab
chore #13: apply SignInUseCase
hyeeum Dec 6, 2024
833364c
feature #13: SignUpUseCase
hyeeum Dec 6, 2024
8383bee
chore #13: apply SignUpUseCase
hyeeum Dec 6, 2024
094db33
feature #13: SignInRepositoryImpl
hyeeum Dec 6, 2024
fdf4887
feature #13: SignUpRepositoryImpl
hyeeum Dec 6, 2024
7cb7dc7
feature #13: MyRepositoryImpl
hyeeum Dec 6, 2024
f228e2f
feature #13: MyRepository
hyeeum Dec 6, 2024
a7ba597
feature #13: SignInRepository
hyeeum Dec 6, 2024
859d8e8
feature #13: SignUpRepository
hyeeum Dec 6, 2024
ad24c45
feature #13: AuthService
hyeeum Dec 6, 2024
0ca0bed
feature #13: MyService
hyeeum Dec 6, 2024
0b0d469
feature #13: MyDataSourceImpl
hyeeum Dec 6, 2024
bcba10b
feature #13: AuthDataSourceImpl
hyeeum Dec 6, 2024
9f0cd0e
feature #13: AuthDataSource
hyeeum Dec 6, 2024
66fa970
feature #13: MyDataSource
hyeeum Dec 6, 2024
92f4d78
chore #13: DataSourceModule
hyeeum Dec 6, 2024
2bf2804
chore #13: RepositoryModule
hyeeum Dec 6, 2024
ce45e9e
chore #13: ServiceModule
hyeeum Dec 6, 2024
374274f
chore #13: edit DataSourceModule function naming
hyeeum Dec 6, 2024
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.component
package org.sopt.and.core.component
Copy link
Contributor

Choose a reason for hiding this comment

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

core 패키지에는 보통 어떤 친구들을 넣어놓으시는지 궁금해요!


import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.component
package org.sopt.and.core.component

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.component
package org.sopt.and.core.component

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and.component
package org.sopt.and.core.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.sopt.and
package org.sopt.and.core.extension

import android.content.Context
import android.widget.Toast
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.sopt.and.core.navigation

interface MainTabRoute : Route
3 changes: 3 additions & 0 deletions app/src/main/java/org/sopt/and/core/navigation/Route.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.sopt.and.core.navigation

interface Route
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ package org.sopt.and.data.datasource
import org.sopt.and.data.dto.request.RequestSignInDto
import org.sopt.and.data.dto.request.RequestSignUpDto
import org.sopt.and.data.dto.response.BaseResponse
import org.sopt.and.data.dto.response.ResponseUserHobbyDto
import org.sopt.and.data.dto.response.ResponseSignInDto
import org.sopt.and.data.dto.response.ResponseSignUpDto

interface WavveDataSource {
interface AuthDataSource {

Choose a reason for hiding this comment

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

datasource를 이렇게 유형별로 나누는게 좋은 방법이군요!

suspend fun postSignUp(requestSignUpDto: RequestSignUpDto): BaseResponse<ResponseSignUpDto>
suspend fun postSignIn(requestSignInDto: RequestSignInDto): BaseResponse<ResponseSignInDto>
suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.and.data.datasource

import org.sopt.and.data.dto.response.BaseResponse
import org.sopt.and.data.dto.response.ResponseUserHobbyDto

interface MyDataSource {
suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto>
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
package org.sopt.and.data.datasourceimpl

import org.sopt.and.data.datasource.WavveDataSource
import org.sopt.and.data.datasource.AuthDataSource
import org.sopt.and.data.dto.request.RequestSignInDto
import org.sopt.and.data.dto.request.RequestSignUpDto
import org.sopt.and.data.dto.response.BaseResponse
import org.sopt.and.data.dto.response.ResponseUserHobbyDto
import org.sopt.and.data.dto.response.ResponseSignInDto
import org.sopt.and.data.dto.response.ResponseSignUpDto
import org.sopt.and.data.service.WavveService
import org.sopt.and.data.service.AuthService
import javax.inject.Inject

class WavveDataSourceImpl @Inject constructor(
private val wavveService: WavveService
) : WavveDataSource {
class AuthDataSourceImpl @Inject constructor(
private val authService: AuthService
) : AuthDataSource {
override suspend fun postSignUp(requestSignUpDto: RequestSignUpDto): BaseResponse<ResponseSignUpDto> =
wavveService.postSignUp(requestSignUpDto)
authService.postSignUp(requestSignUpDto)

override suspend fun postSignIn(requestSignInDto: RequestSignInDto): BaseResponse<ResponseSignInDto> =
wavveService.postSignIn(requestSignInDto)

override suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto> =
wavveService.getUserHobby()

authService.postSignIn(requestSignInDto)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.and.data.datasourceimpl

import org.sopt.and.data.datasource.MyDataSource
import org.sopt.and.data.dto.response.BaseResponse
import org.sopt.and.data.dto.response.ResponseUserHobbyDto
import org.sopt.and.data.service.MyService
import javax.inject.Inject

class MyDataSourceImpl @Inject constructor(
private val myService: MyService
) : MyDataSource {
override suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto> =
myService.getUserHobby()
}
12 changes: 9 additions & 3 deletions app/src/main/java/org/sopt/and/data/di/DataSourceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,21 @@ import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.and.data.datasource.WavveDataSource
import org.sopt.and.data.datasourceimpl.WavveDataSourceImpl
import org.sopt.and.data.datasource.AuthDataSource
import org.sopt.and.data.datasource.MyDataSource
import org.sopt.and.data.datasourceimpl.AuthDataSourceImpl
import org.sopt.and.data.datasourceimpl.MyDataSourceImpl
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
internal abstract class DataSourceModule {
Copy link
Contributor

Choose a reason for hiding this comment

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

여기에 internal을 붙이시는 이유가 따로 있나요??

@Binds
@Singleton
abstract fun bindsDataSource(myDataSourceImpl: WavveDataSourceImpl): WavveDataSource
abstract fun bindsAuthDataSource(authDataSourceImpl: AuthDataSourceImpl): AuthDataSource

@Binds
@Singleton
abstract fun bindsMyDataSource(MyDataSourceImpl: MyDataSourceImpl): MyDataSource
}

26 changes: 21 additions & 5 deletions app/src/main/java/org/sopt/and/data/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,32 @@ import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.and.data.repositoryimpl.WavveRepositoryImpl
import org.sopt.and.domain.repository.WavveRepository
import org.sopt.and.data.repositoryimpl.MyRepositoryImpl
import org.sopt.and.data.repositoryimpl.SignInRepositoryImpl
import org.sopt.and.data.repositoryimpl.SignUpRepositoryImpl
import org.sopt.and.domain.repository.MyRepository
import org.sopt.and.domain.repository.SignInRepository
import org.sopt.and.domain.repository.SignUpRepository
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
internal abstract class RepositoryModule {
@Binds
@Singleton
abstract fun bindsRepository(
myRepositoryImpl: WavveRepositoryImpl
): WavveRepository
abstract fun bindsSignInRepository(
signInRepositoryImpl: SignInRepositoryImpl
): SignInRepository

@Binds
@Singleton
abstract fun bindsSignUpRepository(
signUpRepositoryImpl: SignUpRepositoryImpl
): SignUpRepository

@Binds
@Singleton
abstract fun bindsMyRepository(
myRepositoryImpl: MyRepositoryImpl
): MyRepository
}
12 changes: 9 additions & 3 deletions app/src/main/java/org/sopt/and/data/di/ServiceModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import org.sopt.and.data.service.WavveService
import org.sopt.and.data.service.AuthService
import org.sopt.and.data.service.MyService
import retrofit2.Retrofit
import javax.inject.Singleton

Expand All @@ -13,6 +14,11 @@ import javax.inject.Singleton
object ServiceModule {
@Provides
@Singleton
fun providerService(retrofit: Retrofit): WavveService =
retrofit.create(WavveService::class.java)
fun providerAuthService(retrofit: Retrofit): AuthService =
retrofit.create(AuthService::class.java)

@Provides
@Singleton
fun providerMyService(retrofit: Retrofit): MyService =
retrofit.create(MyService::class.java)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.sopt.and.data.repositoryimpl

import org.sopt.and.data.datasource.MyDataSource
import org.sopt.and.domain.entity.response.ResponseHobbyEntity
import org.sopt.and.domain.repository.MyRepository
import javax.inject.Inject

class MyRepositoryImpl @Inject constructor(
private val myDataSource: MyDataSource
) : MyRepository {
override suspend fun getHobby(): Result<ResponseHobbyEntity> = runCatching {
myDataSource.getUserHobby().result.toEntity()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.and.data.repositoryimpl

import org.sopt.and.data.datasource.AuthDataSource
import org.sopt.and.data.dto.request.toDto
import org.sopt.and.domain.entity.request.RequestSignInEntity
import org.sopt.and.domain.entity.response.ResponseSignInEntity
import org.sopt.and.domain.repository.SignInRepository
import javax.inject.Inject

class SignInRepositoryImpl @Inject constructor(
private val authDataSource: AuthDataSource
) : SignInRepository {
override suspend fun signIn(body: RequestSignInEntity): Result<ResponseSignInEntity> =
runCatching {
authDataSource.postSignIn(body.toDto()).result.toEntity()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.sopt.and.data.repositoryimpl

import org.sopt.and.data.datasource.AuthDataSource
import org.sopt.and.data.dto.request.toDto
import org.sopt.and.domain.entity.request.RequestSignUpEntity
import org.sopt.and.domain.entity.response.ResponseSignUpEntity
import org.sopt.and.domain.repository.SignUpRepository
import javax.inject.Inject

class SignUpRepositoryImpl @Inject constructor(
private val authDataSource: AuthDataSource
) : SignUpRepository {
override suspend fun signUp(body: RequestSignUpEntity): Result<ResponseSignUpEntity> =
runCatching {
authDataSource.postSignUp(body.toDto()).result.toEntity()
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ package org.sopt.and.data.service
import org.sopt.and.data.dto.request.RequestSignInDto
import org.sopt.and.data.dto.request.RequestSignUpDto
import org.sopt.and.data.dto.response.BaseResponse
import org.sopt.and.data.dto.response.ResponseUserHobbyDto
import org.sopt.and.data.dto.response.ResponseSignInDto
import org.sopt.and.data.dto.response.ResponseSignUpDto
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.POST

interface WavveService {
interface AuthService {
@POST("/user")
suspend fun postSignUp(
@Body body: RequestSignUpDto
Expand All @@ -20,7 +18,4 @@ interface WavveService {
suspend fun postSignIn(
@Body body: RequestSignInDto
): BaseResponse<ResponseSignInDto>

@GET("/user/my-hobby")
suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto>
}
10 changes: 10 additions & 0 deletions app/src/main/java/org/sopt/and/data/service/MyService.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.sopt.and.data.service

import org.sopt.and.data.dto.response.BaseResponse
import org.sopt.and.data.dto.response.ResponseUserHobbyDto
import retrofit2.http.GET

interface MyService {
@GET("/user/my-hobby")
suspend fun getUserHobby(): BaseResponse<ResponseUserHobbyDto>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.sopt.and.domain.repository

import org.sopt.and.domain.entity.response.ResponseHobbyEntity

interface MyRepository {
suspend fun getHobby(): Result<ResponseHobbyEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.and.domain.repository

import org.sopt.and.domain.entity.request.RequestSignInEntity
import org.sopt.and.domain.entity.response.ResponseSignInEntity

interface SignInRepository {
suspend fun signIn(body: RequestSignInEntity): Result<ResponseSignInEntity>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.sopt.and.domain.repository

import org.sopt.and.domain.entity.request.RequestSignUpEntity
import org.sopt.and.domain.entity.response.ResponseSignUpEntity

interface SignUpRepository {
suspend fun signUp(body: RequestSignUpEntity): Result<ResponseSignUpEntity>
}

This file was deleted.

12 changes: 12 additions & 0 deletions app/src/main/java/org/sopt/and/domain/usecase/MyUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.sopt.and.domain.usecase

import org.sopt.and.domain.entity.response.ResponseHobbyEntity
import org.sopt.and.domain.repository.MyRepository
import javax.inject.Inject

class MyUseCase @Inject constructor(
private val myRepository: MyRepository
) {
suspend operator fun invoke(): Result<ResponseHobbyEntity> =
myRepository.getHobby()
}
13 changes: 13 additions & 0 deletions app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.and.domain.usecase

import org.sopt.and.domain.entity.request.RequestSignInEntity
import org.sopt.and.domain.entity.response.ResponseSignInEntity
import org.sopt.and.domain.repository.SignInRepository
import javax.inject.Inject

class SignInUseCase @Inject constructor(
private val signInRepository: SignInRepository
) {
suspend operator fun invoke(signInEntity: RequestSignInEntity): Result<ResponseSignInEntity> =
signInRepository.signIn(signInEntity)
}
13 changes: 13 additions & 0 deletions app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.sopt.and.domain.usecase

import org.sopt.and.domain.entity.request.RequestSignUpEntity
import org.sopt.and.domain.entity.response.ResponseSignUpEntity
import org.sopt.and.domain.repository.SignUpRepository
import javax.inject.Inject

class SignUpUseCase @Inject constructor(
private val signUpRepository: SignUpRepository
) {
suspend operator fun invoke(signUpEntity: RequestSignUpEntity): Result<ResponseSignUpEntity> =
signUpRepository.signUp(signUpEntity)
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import kotlinx.serialization.Serializable
import org.sopt.and.feature.main.MainTabRoute
import org.sopt.and.core.navigation.MainTabRoute

fun NavController.navigateHome(
navOptions: NavOptions
Expand Down
Loading