From 7a7e46ba74e26f52032bfa2582ff167a262db5b6 Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Sun, 8 Dec 2024 18:09:33 +0900 Subject: [PATCH] =?UTF-8?q?[feature]=20#9=20-=20repository,=20usecase=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/sopt/and/data/api/Api.kt | 60 ------------------- .../main/java/org/sopt/and/data/api/Auth.kt | 25 -------- .../main/java/org/sopt/and/data/api/Hobby.kt | 13 ---- .../main/java/org/sopt/and/data/dto/Auth.kt | 48 --------------- app/src/main/java/org/sopt/and/data/dto/My.kt | 18 ------ .../java/org/sopt/and/data/mapper/Mapper.kt | 47 +++++++++++++++ .../repositoryimpl/MyHobbyRepositoryImpl.kt | 2 +- .../repositoryimpl/SignInRepositoryImpl.kt | 2 +- .../repositoryimpl/SignUpRepositoryImpl.kt | 2 +- .../org/sopt/and/data/service/ApiFactory.kt | 36 +++++++++++ .../org/sopt/and/data/service/AppContext.kt | 13 ++++ .../sopt/and/data/service/AuthInterceptor.kt | 32 ++++++++++ .../org/sopt/and/data/service/TokenManager.kt | 32 ++++++++++ .../org/sopt/and/data/service/UserService.kt | 21 +++++++ .../sopt/and/domain/model/MyHobbyEntity.kt | 5 ++ .../org/sopt/and/domain/model/SignInEntity.kt | 6 ++ .../and/domain/model/SignInResponseEntity.kt | 7 +++ .../org/sopt/and/domain/model/SignUpEntity.kt | 7 +++ .../and/domain/model/SignUpReseponseEntity.kt | 7 +++ .../domain/repository/MyHobbyRepository.kt | 20 +++++++ .../and/domain/repository/SignInRepository.kt | 21 +++++++ .../and/domain/repository/SignUpRepository.kt | 21 +++++++ .../sopt/and/domain/usecase/MyHobbyUseCase.kt | 11 ++++ .../sopt/and/domain/usecase/SignInUseCase.kt | 12 ++++ .../sopt/and/domain/usecase/SignUpUseCase.kt | 12 ++++ 25 files changed, 313 insertions(+), 167 deletions(-) delete mode 100644 app/src/main/java/org/sopt/and/data/api/Api.kt delete mode 100644 app/src/main/java/org/sopt/and/data/api/Auth.kt delete mode 100644 app/src/main/java/org/sopt/and/data/api/Hobby.kt delete mode 100644 app/src/main/java/org/sopt/and/data/dto/Auth.kt delete mode 100644 app/src/main/java/org/sopt/and/data/dto/My.kt create mode 100644 app/src/main/java/org/sopt/and/data/mapper/Mapper.kt create mode 100644 app/src/main/java/org/sopt/and/data/service/ApiFactory.kt create mode 100644 app/src/main/java/org/sopt/and/data/service/AppContext.kt create mode 100644 app/src/main/java/org/sopt/and/data/service/AuthInterceptor.kt create mode 100644 app/src/main/java/org/sopt/and/data/service/TokenManager.kt create mode 100644 app/src/main/java/org/sopt/and/data/service/UserService.kt create mode 100644 app/src/main/java/org/sopt/and/domain/model/MyHobbyEntity.kt create mode 100644 app/src/main/java/org/sopt/and/domain/model/SignInEntity.kt create mode 100644 app/src/main/java/org/sopt/and/domain/model/SignInResponseEntity.kt create mode 100644 app/src/main/java/org/sopt/and/domain/model/SignUpEntity.kt create mode 100644 app/src/main/java/org/sopt/and/domain/model/SignUpReseponseEntity.kt create mode 100644 app/src/main/java/org/sopt/and/domain/repository/MyHobbyRepository.kt create mode 100644 app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt create mode 100644 app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt create mode 100644 app/src/main/java/org/sopt/and/domain/usecase/MyHobbyUseCase.kt create mode 100644 app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt create mode 100644 app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt diff --git a/app/src/main/java/org/sopt/and/data/api/Api.kt b/app/src/main/java/org/sopt/and/data/api/Api.kt deleted file mode 100644 index adbe3e8a..00000000 --- a/app/src/main/java/org/sopt/and/data/api/Api.kt +++ /dev/null @@ -1,60 +0,0 @@ -package org.sopt.and.data.api - -import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory -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 org.sopt.and.BuildConfig -import retrofit2.Retrofit -import javax.inject.Singleton - -@Module -@InstallIn(SingletonComponent::class) -object ApiFactory { - private const val BASE_URL: String = BuildConfig.BASE_URL - - @Provides - @Singleton - fun provideOkHttpClient(): OkHttpClient { - val loggingInterceptor = HttpLoggingInterceptor().apply { - level = HttpLoggingInterceptor.Level.BODY - } - return OkHttpClient.Builder() - .addInterceptor(loggingInterceptor) - .build() - } - - @Provides - @Singleton - fun provideRetrofit(client: OkHttpClient): Retrofit { - return Retrofit.Builder() - .baseUrl(BASE_URL) - .client(client) - .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) - .build() - } - - @Provides - @Singleton - fun provideUserRegistrationService(retrofit: Retrofit): UserRegistrationService { - return retrofit.create(UserRegistrationService::class.java) - } - - @Provides - @Singleton - fun provideLoginService(retrofit: Retrofit): LoginService { - return retrofit.create(LoginService::class.java) - } - - @Provides - @Singleton - fun provideHobbyService(retrofit: Retrofit): HobbyService { - return retrofit.create(HobbyService::class.java) - } - -} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/api/Auth.kt b/app/src/main/java/org/sopt/and/data/api/Auth.kt deleted file mode 100644 index 3b662052..00000000 --- a/app/src/main/java/org/sopt/and/data/api/Auth.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.sopt.and.data.api - -import org.sopt.and.data.api.dto.RequestLoginData -import org.sopt.and.data.api.dto.RequestUserRegistrationData -import org.sopt.and.data.api.dto.ResponseLogin -import org.sopt.and.data.api.dto.ResponseUserRegistration -import retrofit2.Response -import retrofit2.http.Body -import retrofit2.http.POST - - -interface UserRegistrationService { - @POST("/user") - suspend fun postUserRegistration( - @Body userRequest: RequestUserRegistrationData - ): Response -} - -interface LoginService { - @POST("/login") - suspend fun postLogin( - @Body loginRequeset: RequestLoginData - ): Response -} - diff --git a/app/src/main/java/org/sopt/and/data/api/Hobby.kt b/app/src/main/java/org/sopt/and/data/api/Hobby.kt deleted file mode 100644 index 4f718a85..00000000 --- a/app/src/main/java/org/sopt/and/data/api/Hobby.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.sopt.and.data.api - -import org.sopt.and.data.api.dto.ResponseMyHobbyData -import retrofit2.Response -import retrofit2.http.GET -import retrofit2.http.Header - -interface HobbyService { - @GET("/user/my-hobby") - suspend fun getHobby( - @Header("token") token: String? - ): Response -} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/dto/Auth.kt b/app/src/main/java/org/sopt/and/data/dto/Auth.kt deleted file mode 100644 index 132866f8..00000000 --- a/app/src/main/java/org/sopt/and/data/dto/Auth.kt +++ /dev/null @@ -1,48 +0,0 @@ -package org.sopt.and.data.api.dto - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -/* 유저 등록 */ -@Serializable -data class RequestUserRegistrationData( - @SerialName("username") - val userName: String, - @SerialName("password") - val password: String, - @SerialName("hobby") - val hobby: String -) - -@Serializable -data class ResponseUserRegistration( - @SerialName("result") - val result: ResultUserNo -) - -@Serializable -data class ResultUserNo( - @SerialName("no") - val no: Int -) - -/* 로그인 */ -@Serializable -data class RequestLoginData( - @SerialName("username") - val userName: String, - @SerialName("password") - val password: String -) - -@Serializable -data class ResponseLogin( - @SerialName("result") - val result: ResultToken -) - -@Serializable -data class ResultToken( - @SerialName("token") - val token: String -) \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/dto/My.kt b/app/src/main/java/org/sopt/and/data/dto/My.kt deleted file mode 100644 index 364c2c40..00000000 --- a/app/src/main/java/org/sopt/and/data/dto/My.kt +++ /dev/null @@ -1,18 +0,0 @@ -package org.sopt.and.data.api.dto - - -import kotlinx.serialization.SerialName -import kotlinx.serialization.Serializable - -/* 내 취미 조회 */ -@Serializable -data class ResponseMyHobbyData( - @SerialName("result") - val result: ResponseMyHobbyDataResult -) - -@Serializable -data class ResponseMyHobbyDataResult( - @SerialName("hobby") - val hobby: String -) diff --git a/app/src/main/java/org/sopt/and/data/mapper/Mapper.kt b/app/src/main/java/org/sopt/and/data/mapper/Mapper.kt new file mode 100644 index 00000000..3ad9c7dc --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/mapper/Mapper.kt @@ -0,0 +1,47 @@ +package org.sopt.and.data.mapper + +import org.sopt.and.data.model.request.SignInRequestDto +import org.sopt.and.data.model.request.SignUpRequestDto +import org.sopt.and.data.model.response.GetMyHobbyResponseResultDto +import org.sopt.and.data.model.response.SignInResponseDto +import org.sopt.and.data.model.response.SignUpResponseDto +import org.sopt.and.domain.model.MyHobbyEntity +import org.sopt.and.domain.model.SignInInformationEntity +import org.sopt.and.domain.model.SignInResponseEntity +import org.sopt.and.domain.model.SignUpInformationEntity +import org.sopt.and.domain.model.SignUpResponseEntity +import retrofit2.Response + +object Mapper { + fun toMyHobbyEntity(getHobbyResponseResultDto: GetMyHobbyResponseResultDto) = + MyHobbyEntity(myHobby = getHobbyResponseResultDto.myHobby) + + fun toSignUpResponseEntity(signUpResponseDto: Response) = + signUpResponseDto.body()?.result?.let { + SignUpResponseEntity( + no = it.no, + status = signUpResponseDto.code(), + code = signUpResponseDto.body()!!.code + ) + } + + fun toSignInResponseEntity(signInResponseDto: Response) = + signInResponseDto.body()?.result?.let { + SignInResponseEntity( + token = it.token, + status = signInResponseDto.code(), + code = signInResponseDto.body()!!.code + ) + } + + fun toSignInRequestDto(signInInformationEntity: SignInInformationEntity) = SignInRequestDto( + username = signInInformationEntity.username, + password = signInInformationEntity.password + ) + + fun toSignUpRequestDto(signUpInformationEntity: SignUpInformationEntity) = SignUpRequestDto( + username = signUpInformationEntity.username, + password = signUpInformationEntity.password, + hobby = signUpInformationEntity.hobby + ) +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/MyHobbyRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/MyHobbyRepositoryImpl.kt index 2c463ab9..6f90a3d8 100644 --- a/app/src/main/java/org/sopt/and/data/repositoryimpl/MyHobbyRepositoryImpl.kt +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/MyHobbyRepositoryImpl.kt @@ -3,7 +3,7 @@ package org.sopt.and.data.repositoryimpl import org.sopt.and.data.datasource.GetMyHobbyDataSource import org.sopt.and.data.mapper.Mapper import org.sopt.and.domain.model.MyHobbyEntity -import org.sopt.and.domain.repository.GetMyHobbyRepository +import org.sopt.and.domain.usecase.GetMyHobbyRepository class MyHobbyRepositoryImpl( private val getMyHobbyDataSource: GetMyHobbyDataSource diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt index e3819221..fdb273b0 100644 --- a/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt @@ -4,7 +4,7 @@ import org.sopt.and.data.datasource.SignInDataSource import org.sopt.and.data.mapper.Mapper import org.sopt.and.domain.model.SignInInformationEntity import org.sopt.and.domain.model.SignInResponseEntity -import org.sopt.and.domain.repository.SignInRepository +import org.sopt.and.domain.usecase.SignInRepository class SignInRepositoryImpl( private val signInDataSource: SignInDataSource diff --git a/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt index 91567a91..abd0a4d7 100644 --- a/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt @@ -4,7 +4,7 @@ import org.sopt.and.data.datasource.SignUpDataSource import org.sopt.and.data.mapper.Mapper import org.sopt.and.domain.model.SignUpInformationEntity import org.sopt.and.domain.model.SignUpResponseEntity -import org.sopt.and.domain.repository.SignUpRepository +import org.sopt.and.domain.usecase.SignUpRepository class SignUpRepositoryImpl( private val signUpDataSource: SignUpDataSource diff --git a/app/src/main/java/org/sopt/and/data/service/ApiFactory.kt b/app/src/main/java/org/sopt/and/data/service/ApiFactory.kt new file mode 100644 index 00000000..a4a1b68a --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/service/ApiFactory.kt @@ -0,0 +1,36 @@ +package org.sopt.and.data.service + +import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory +import kotlinx.serialization.json.Json +import okhttp3.MediaType.Companion.toMediaType +import okhttp3.OkHttpClient +import okhttp3.logging.HttpLoggingInterceptor +import org.sopt.and.BuildConfig +import retrofit2.Retrofit + +object ApiFactory { + private const val BASE_URL: String = BuildConfig.BASE_URL + + private val okHttpClient: OkHttpClient by lazy { + OkHttpClient.Builder() + .addInterceptor(AuthInterceptor(AppContext.get())) + .addInterceptor(HttpLoggingInterceptor().apply { + level = HttpLoggingInterceptor.Level.BODY + }) + .build() + } + + val retrofit: Retrofit by lazy { + Retrofit.Builder() + .baseUrl(BASE_URL) + .client(okHttpClient) + .addConverterFactory(Json.asConverterFactory("application/json".toMediaType())) + .build() + } + + inline fun create(): T = retrofit.create(T::class.java) +} + +object ServicePool { + val userService: UserService by lazy { ApiFactory.create() } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/service/AppContext.kt b/app/src/main/java/org/sopt/and/data/service/AppContext.kt new file mode 100644 index 00000000..29eb7ae9 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/service/AppContext.kt @@ -0,0 +1,13 @@ +package org.sopt.and.data.service + +import android.content.Context + +object AppContext { + private lateinit var applicationContext: Context + + fun init(context: Context) { + applicationContext = context.applicationContext + } + + fun get(): Context = applicationContext +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/service/AuthInterceptor.kt b/app/src/main/java/org/sopt/and/data/service/AuthInterceptor.kt new file mode 100644 index 00000000..c9f89e44 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/service/AuthInterceptor.kt @@ -0,0 +1,32 @@ +package org.sopt.and.data.service + +import android.content.Context +import kotlinx.coroutines.flow.first +import kotlinx.coroutines.runBlocking +import okhttp3.Interceptor +import okhttp3.Response + +class AuthInterceptor(context: Context) : Interceptor { + private val tokenManager = TokenManager(context) + + override fun intercept(chain: Interceptor.Chain): Response { + var token: String? + + runBlocking { + token = tokenManager.getToken().first() + } + + val request = chain.request().newBuilder() + .apply { + if (token != null) { + addHeader(HEADER_NAME, token!!) + } + } + .build() + return chain.proceed(request) + } + + companion object { + const val HEADER_NAME = "token" + } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/service/TokenManager.kt b/app/src/main/java/org/sopt/and/data/service/TokenManager.kt new file mode 100644 index 00000000..6f8407b8 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/service/TokenManager.kt @@ -0,0 +1,32 @@ +package org.sopt.and.data.service + +import android.content.Context +import androidx.datastore.preferences.core.edit +import androidx.datastore.preferences.core.stringPreferencesKey +import androidx.datastore.preferences.preferencesDataStore +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.map +import org.sopt.and.data.service.TokenManager.Companion.DATASTORE_NAME + +val Context.dataStore by preferencesDataStore(DATASTORE_NAME) + +class TokenManager(private val context: Context) { + private val TOKEN_KEY = stringPreferencesKey(TOKEN_NAME) + + fun getToken(): Flow { + return context.dataStore.data.map { preferences -> + preferences[TOKEN_KEY] + } + } + + suspend fun saveToken(token: String) { + context.dataStore.edit { preferences -> + preferences[TOKEN_KEY] = token + } + } + + companion object { + const val DATASTORE_NAME = "token" + const val TOKEN_NAME = "auth_token" + } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/service/UserService.kt b/app/src/main/java/org/sopt/and/data/service/UserService.kt new file mode 100644 index 00000000..728e3aa7 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/service/UserService.kt @@ -0,0 +1,21 @@ +package org.sopt.and.data.service + +import org.sopt.and.data.model.request.SignInRequestDto +import org.sopt.and.data.model.request.SignUpRequestDto +import org.sopt.and.data.model.response.MyHobbyResponseDto +import org.sopt.and.data.model.response.SignInResponseDto +import org.sopt.and.data.model.response.SignUpResponseDto +import retrofit2.Response +import retrofit2.http.Body +import retrofit2.http.GET +import retrofit2.http.POST + +interface UserService { + suspend fun signUp(@Body request: SignUpRequestDto): Response + + @POST("/login") + suspend fun signIn(@Body request: SignInRequestDto): Response + + @GET("/user/my-hobby") + suspend fun getMyHobby(): GetMyHobbyResponseDto +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/domain/model/MyHobbyEntity.kt b/app/src/main/java/org/sopt/and/domain/model/MyHobbyEntity.kt new file mode 100644 index 00000000..5d97c017 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/model/MyHobbyEntity.kt @@ -0,0 +1,5 @@ +package org.sopt.and.domain.model + +data class MyHobbyEntity( + val myHobby: String +) diff --git a/app/src/main/java/org/sopt/and/domain/model/SignInEntity.kt b/app/src/main/java/org/sopt/and/domain/model/SignInEntity.kt new file mode 100644 index 00000000..fa33f839 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/model/SignInEntity.kt @@ -0,0 +1,6 @@ +package org.sopt.and.domain.model + +data class SignInInformationEntity( + val username: String, + val password: String +) diff --git a/app/src/main/java/org/sopt/and/domain/model/SignInResponseEntity.kt b/app/src/main/java/org/sopt/and/domain/model/SignInResponseEntity.kt new file mode 100644 index 00000000..d73a3290 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/model/SignInResponseEntity.kt @@ -0,0 +1,7 @@ +package org.sopt.and.domain.model + +data class SignInResponseEntity( + val token: String? = null, + val status: Int? = null, + val code: String? = null +) diff --git a/app/src/main/java/org/sopt/and/domain/model/SignUpEntity.kt b/app/src/main/java/org/sopt/and/domain/model/SignUpEntity.kt new file mode 100644 index 00000000..dcfcaab3 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/model/SignUpEntity.kt @@ -0,0 +1,7 @@ +package org.sopt.and.domain.model + +data class SignUpInformationEntity( + val username: String, + val password: String, + val hobby: String +) diff --git a/app/src/main/java/org/sopt/and/domain/model/SignUpReseponseEntity.kt b/app/src/main/java/org/sopt/and/domain/model/SignUpReseponseEntity.kt new file mode 100644 index 00000000..16dde9de --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/model/SignUpReseponseEntity.kt @@ -0,0 +1,7 @@ +package org.sopt.and.domain.model + +data class SignUpResponseEntity( + val no: Int? = null, + val code: String? = null, + val status: Int? = null +) diff --git a/app/src/main/java/org/sopt/and/domain/repository/MyHobbyRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/MyHobbyRepository.kt new file mode 100644 index 00000000..a3d88e32 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/MyHobbyRepository.kt @@ -0,0 +1,20 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.data.datasource.GetMyHobbyDataSource +import org.sopt.and.data.repositoryimpl.GetMyHobbyRepositoryImpl +import org.sopt.and.data.service.ServicePool +import org.sopt.and.domain.model.MyHobbyEntity + +interface MyHobbyRepository { + suspend fun getMyHobby(): Result + + companion object { + fun create(): GetMyHobbyRepositoryImpl { + return GetMyHobbyRepositoryImpl( + GetMyHobbyDataSource( + ServicePool.userService + ) + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt new file mode 100644 index 00000000..9a7a39a4 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/SignInRepository.kt @@ -0,0 +1,21 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.data.datasource.SignInDataSource +import org.sopt.and.data.repositoryimpl.SignInRepositoryImpl +import org.sopt.and.data.service.ServicePool +import org.sopt.and.domain.model.SignInInformationEntity +import org.sopt.and.domain.model.SignInResponseEntity + +interface SignInRepository { + suspend fun signIn(request: SignInInformationEntity): Result + + companion object { + fun create(): SignInRepositoryImpl { + return SignInRepositoryImpl( + SignInDataSource( + ServicePool.userService + ) + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt b/app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt new file mode 100644 index 00000000..f8731170 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/repository/SignUpRepository.kt @@ -0,0 +1,21 @@ +package org.sopt.and.domain.repository + +import org.sopt.and.data.datasource.SignUpDataSource +import org.sopt.and.data.repositoryimpl.SignUpRepositoryImpl +import org.sopt.and.data.service.ServicePool +import org.sopt.and.domain.model.SignUpInformationEntity +import org.sopt.and.domain.model.SignUpResponseEntity + +interface SignUpRepository { + suspend fun signUp(request: SignUpInformationEntity): Result + + companion object { + fun create(): SignUpRepositoryImpl { + return SignUpRepositoryImpl( + signUpDataSource = SignUpDataSource( + userService = ServicePool.userService + ) + ) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/domain/usecase/MyHobbyUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/MyHobbyUseCase.kt new file mode 100644 index 00000000..331dd8a7 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/usecase/MyHobbyUseCase.kt @@ -0,0 +1,11 @@ +package org.sopt.and.domain.usecase + +import org.sopt.and.domain.model.MyHobbyEntity +import org.sopt.and.domain.repository.GetMyHobbyRepository + +class MyHobbyUseCase( + private val getMyHobbyRepository: GetMyHobbyRepository +) { + suspend operator fun invoke(): Result = + getMyHobbyRepository.getMyHobby() +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt new file mode 100644 index 00000000..eb1504db --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/usecase/SignInUseCase.kt @@ -0,0 +1,12 @@ +package org.sopt.and.domain.usecase + +import org.sopt.and.domain.model.SignInInformationEntity +import org.sopt.and.domain.model.SignInResponseEntity +import org.sopt.and.domain.repository.SignInRepository + +class SignInUseCase( + private val signInRepository: SignInRepository +) { + suspend operator fun invoke(request: SignInInformationEntity): Result = + signInRepository.signIn(request = request) +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt b/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt new file mode 100644 index 00000000..3df221d3 --- /dev/null +++ b/app/src/main/java/org/sopt/and/domain/usecase/SignUpUseCase.kt @@ -0,0 +1,12 @@ +package org.sopt.and.domain.usecase + +import org.sopt.and.domain.model.SignUpInformationEntity +import org.sopt.and.domain.model.SignUpResponseEntity +import org.sopt.and.domain.repository.SignUpRepository + +class SignUpUseCase( + private val signUpRepository: SignUpRepository +) { + suspend operator fun invoke(request: SignUpInformationEntity): Result = + signUpRepository.signUp(request = request) +} \ No newline at end of file