From b766625fb6e9c5f538187a4b0a2b1cd34e7079aa Mon Sep 17 00:00:00 2001 From: sayyyho <323psh@naver.com> Date: Sun, 8 Dec 2024 17:56:55 +0900 Subject: [PATCH] =?UTF-8?q?[chore]=20#9=20-=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/sopt/and/{ => data}/api/Api.kt | 2 +- .../java/org/sopt/and/{ => data}/api/Auth.kt | 10 ++++----- .../java/org/sopt/and/{ => data}/api/Hobby.kt | 4 ++-- .../and/data/datasource/MyHobbyDataSource.kt | 10 +++++++++ .../and/data/datasource/SignInDataSource.kt | 13 +++++++++++ .../and/data/datasource/SignUpDataSource.kt | 13 +++++++++++ .../java/org/sopt/and/{ => data}/dto/Auth.kt | 2 +- .../java/org/sopt/and/{ => data}/dto/My.kt | 2 +- .../data/model/request/SignInRequestDto.kt | 9 ++++++++ .../data/model/request/SignUpRequestDto.kt | 10 +++++++++ .../data/model/response/MyHobbyResponseDto.kt | 16 ++++++++++++++ .../data/model/response/SignInResponseDto.kt | 14 ++++++++++++ .../data/model/response/SignUpReponseDto.kt | 14 ++++++++++++ .../repositoryimpl/MyHobbyRepositoryImpl.kt | 15 +++++++++++++ .../repositoryimpl/SignInRepositoryImpl.kt | 22 +++++++++++++++++++ .../repositoryimpl/SignUpRepositoryImpl.kt | 22 +++++++++++++++++++ .../viewmodel/SignViewModel.kt | 12 +++++----- 17 files changed, 174 insertions(+), 16 deletions(-) rename app/src/main/java/org/sopt/and/{ => data}/api/Api.kt (98%) rename app/src/main/java/org/sopt/and/{ => data}/api/Auth.kt (63%) rename app/src/main/java/org/sopt/and/{ => data}/api/Hobby.kt (74%) create mode 100644 app/src/main/java/org/sopt/and/data/datasource/MyHobbyDataSource.kt create mode 100644 app/src/main/java/org/sopt/and/data/datasource/SignInDataSource.kt create mode 100644 app/src/main/java/org/sopt/and/data/datasource/SignUpDataSource.kt rename app/src/main/java/org/sopt/and/{ => data}/dto/Auth.kt (96%) rename app/src/main/java/org/sopt/and/{ => data}/dto/My.kt (90%) create mode 100644 app/src/main/java/org/sopt/and/data/model/request/SignInRequestDto.kt create mode 100644 app/src/main/java/org/sopt/and/data/model/request/SignUpRequestDto.kt create mode 100644 app/src/main/java/org/sopt/and/data/model/response/MyHobbyResponseDto.kt create mode 100644 app/src/main/java/org/sopt/and/data/model/response/SignInResponseDto.kt create mode 100644 app/src/main/java/org/sopt/and/data/model/response/SignUpReponseDto.kt create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/MyHobbyRepositoryImpl.kt create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt create mode 100644 app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt rename app/src/main/java/org/sopt/and/{ => presentation}/viewmodel/SignViewModel.kt (95%) diff --git a/app/src/main/java/org/sopt/and/api/Api.kt b/app/src/main/java/org/sopt/and/data/api/Api.kt similarity index 98% rename from app/src/main/java/org/sopt/and/api/Api.kt rename to app/src/main/java/org/sopt/and/data/api/Api.kt index 36ac5ad1..adbe3e8a 100644 --- a/app/src/main/java/org/sopt/and/api/Api.kt +++ b/app/src/main/java/org/sopt/and/data/api/Api.kt @@ -1,4 +1,4 @@ -package org.sopt.and.api +package org.sopt.and.data.api import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory import dagger.Module diff --git a/app/src/main/java/org/sopt/and/api/Auth.kt b/app/src/main/java/org/sopt/and/data/api/Auth.kt similarity index 63% rename from app/src/main/java/org/sopt/and/api/Auth.kt rename to app/src/main/java/org/sopt/and/data/api/Auth.kt index a26a42db..3b662052 100644 --- a/app/src/main/java/org/sopt/and/api/Auth.kt +++ b/app/src/main/java/org/sopt/and/data/api/Auth.kt @@ -1,9 +1,9 @@ -package org.sopt.and.api +package org.sopt.and.data.api -import org.sopt.and.dto.RequestLoginData -import org.sopt.and.dto.RequestUserRegistrationData -import org.sopt.and.dto.ResponseLogin -import org.sopt.and.dto.ResponseUserRegistration +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 diff --git a/app/src/main/java/org/sopt/and/api/Hobby.kt b/app/src/main/java/org/sopt/and/data/api/Hobby.kt similarity index 74% rename from app/src/main/java/org/sopt/and/api/Hobby.kt rename to app/src/main/java/org/sopt/and/data/api/Hobby.kt index c1784eb0..4f718a85 100644 --- a/app/src/main/java/org/sopt/and/api/Hobby.kt +++ b/app/src/main/java/org/sopt/and/data/api/Hobby.kt @@ -1,6 +1,6 @@ -package org.sopt.and.api +package org.sopt.and.data.api -import org.sopt.and.dto.ResponseMyHobbyData +import org.sopt.and.data.api.dto.ResponseMyHobbyData import retrofit2.Response import retrofit2.http.GET import retrofit2.http.Header diff --git a/app/src/main/java/org/sopt/and/data/datasource/MyHobbyDataSource.kt b/app/src/main/java/org/sopt/and/data/datasource/MyHobbyDataSource.kt new file mode 100644 index 00000000..628ef055 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/datasource/MyHobbyDataSource.kt @@ -0,0 +1,10 @@ +package org.sopt.and.data.datasource + +import org.sopt.and.data.model.response.MyHobbyResponseDto +import org.sopt.and.data.service.UserService + +class MyHobbyDataSource( + private val userService: UserService +) { + suspend fun getMyHobby(): MyHobbyResponseDto = userService.getMyHobby() +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/datasource/SignInDataSource.kt b/app/src/main/java/org/sopt/and/data/datasource/SignInDataSource.kt new file mode 100644 index 00000000..952c8783 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/datasource/SignInDataSource.kt @@ -0,0 +1,13 @@ +package org.sopt.and.data.datasource + +import org.sopt.and.data.model.request.SignInRequestDto +import org.sopt.and.data.model.response.SignInResponseDto +import org.sopt.and.data.service.UserService +import retrofit2.Response + +class SignInDataSource( + private val userService: UserService +) { + suspend fun signIn(request: SignInRequestDto): Response = + userService.signIn(request = request) +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/datasource/SignUpDataSource.kt b/app/src/main/java/org/sopt/and/data/datasource/SignUpDataSource.kt new file mode 100644 index 00000000..9f649e26 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/datasource/SignUpDataSource.kt @@ -0,0 +1,13 @@ +package org.sopt.and.data.datasource + +import org.sopt.and.data.model.request.SignUpRequestDto +import org.sopt.and.data.model.response.SignUpResponseDto +import org.sopt.and.data.service.UserService +import retrofit2.Response + +class SignUpDataSource( + private val userService: UserService +) { + suspend fun signUp(request: SignUpRequestDto): Response = + userService.signUp(request = request) +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/dto/Auth.kt b/app/src/main/java/org/sopt/and/data/dto/Auth.kt similarity index 96% rename from app/src/main/java/org/sopt/and/dto/Auth.kt rename to app/src/main/java/org/sopt/and/data/dto/Auth.kt index f26a1496..132866f8 100644 --- a/app/src/main/java/org/sopt/and/dto/Auth.kt +++ b/app/src/main/java/org/sopt/and/data/dto/Auth.kt @@ -1,4 +1,4 @@ -package org.sopt.and.dto +package org.sopt.and.data.api.dto import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable diff --git a/app/src/main/java/org/sopt/and/dto/My.kt b/app/src/main/java/org/sopt/and/data/dto/My.kt similarity index 90% rename from app/src/main/java/org/sopt/and/dto/My.kt rename to app/src/main/java/org/sopt/and/data/dto/My.kt index 99e47962..364c2c40 100644 --- a/app/src/main/java/org/sopt/and/dto/My.kt +++ b/app/src/main/java/org/sopt/and/data/dto/My.kt @@ -1,4 +1,4 @@ -package org.sopt.and.dto +package org.sopt.and.data.api.dto import kotlinx.serialization.SerialName diff --git a/app/src/main/java/org/sopt/and/data/model/request/SignInRequestDto.kt b/app/src/main/java/org/sopt/and/data/model/request/SignInRequestDto.kt new file mode 100644 index 00000000..b711c131 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/model/request/SignInRequestDto.kt @@ -0,0 +1,9 @@ +package org.sopt.and.data.model.request + +import kotlinx.serialization.Serializable + +@Serializable +data class SignInRequestDto( + val username: String, + val password: String +) diff --git a/app/src/main/java/org/sopt/and/data/model/request/SignUpRequestDto.kt b/app/src/main/java/org/sopt/and/data/model/request/SignUpRequestDto.kt new file mode 100644 index 00000000..8b85066f --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/model/request/SignUpRequestDto.kt @@ -0,0 +1,10 @@ +package org.sopt.and.data.model.request + +import kotlinx.serialization.Serializable + +@Serializable +data class SignUpRequestDto( + val username: String, + val password: String, + val hobby: String +) diff --git a/app/src/main/java/org/sopt/and/data/model/response/MyHobbyResponseDto.kt b/app/src/main/java/org/sopt/and/data/model/response/MyHobbyResponseDto.kt new file mode 100644 index 00000000..47663316 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/model/response/MyHobbyResponseDto.kt @@ -0,0 +1,16 @@ +package org.sopt.and.data.model.response + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + +@Serializable +data class MyHobbyResponseDto( + val result: MyHobbyResponseResultDto? = null, + val code: String? = null +) + +@Serializable +data class MyHobbyResponseResultDto( + @SerialName("hobby") + val myHobby: String +) \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/data/model/response/SignInResponseDto.kt b/app/src/main/java/org/sopt/and/data/model/response/SignInResponseDto.kt new file mode 100644 index 00000000..1e404b98 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/model/response/SignInResponseDto.kt @@ -0,0 +1,14 @@ +package org.sopt.and.data.model.response + +import kotlinx.serialization.Serializable + +@Serializable +data class SignInResponseDto( + val result: SignInResponseResultDto? = null, + val code: String? = null +) + +@Serializable +data class SignInResponseResultDto( + val token: String +) diff --git a/app/src/main/java/org/sopt/and/data/model/response/SignUpReponseDto.kt b/app/src/main/java/org/sopt/and/data/model/response/SignUpReponseDto.kt new file mode 100644 index 00000000..9e2b938e --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/model/response/SignUpReponseDto.kt @@ -0,0 +1,14 @@ +package org.sopt.and.data.model.response + +import kotlinx.serialization.Serializable + +@Serializable +data class SignUpResponseDto( + val result: SignUpResponseResultDto? = null, + val code: String? = null +) + +@Serializable +data class SignUpResponseResultDto( + val no: Int +) \ 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 new file mode 100644 index 00000000..2c463ab9 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/MyHobbyRepositoryImpl.kt @@ -0,0 +1,15 @@ +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 + +class MyHobbyRepositoryImpl( + private val getMyHobbyDataSource: GetMyHobbyDataSource +) : GetMyHobbyRepository { + override suspend fun getMyHobby(): Result = + runCatching { + getMyHobbyDataSource.getMyHobby().result?.let { Mapper.toMyHobbyEntity(it) }!! + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..e3819221 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignInRepositoryImpl.kt @@ -0,0 +1,22 @@ +package org.sopt.and.data.repositoryimpl + +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 + +class SignInRepositoryImpl( + private val signInDataSource: SignInDataSource +) : SignInRepository { + override suspend fun signIn(request: SignInInformationEntity): Result = + runCatching { + Mapper.toSignInResponseEntity( + signInDataSource.signIn( + Mapper.toSignInRequestDto( + request + ) + ) + )!! + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..91567a91 --- /dev/null +++ b/app/src/main/java/org/sopt/and/data/repositoryimpl/SignUpRepositoryImpl.kt @@ -0,0 +1,22 @@ +package org.sopt.and.data.repositoryimpl + +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 + +class SignUpRepositoryImpl( + private val signUpDataSource: SignUpDataSource +) : SignUpRepository { + override suspend fun signUp(request: SignUpInformationEntity): Result = + runCatching { + Mapper.toSignUpResponseEntity( + signUpDataSource.signUp( + Mapper.toSignUpRequestDto( + request + ) + ) + )!! + } +} \ No newline at end of file diff --git a/app/src/main/java/org/sopt/and/viewmodel/SignViewModel.kt b/app/src/main/java/org/sopt/and/presentation/viewmodel/SignViewModel.kt similarity index 95% rename from app/src/main/java/org/sopt/and/viewmodel/SignViewModel.kt rename to app/src/main/java/org/sopt/and/presentation/viewmodel/SignViewModel.kt index 833f4e08..55bf5aa0 100644 --- a/app/src/main/java/org/sopt/and/viewmodel/SignViewModel.kt +++ b/app/src/main/java/org/sopt/and/presentation/viewmodel/SignViewModel.kt @@ -12,12 +12,12 @@ import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import org.sopt.and.api.HobbyService -import org.sopt.and.api.LoginService -import org.sopt.and.api.UserRegistrationService -import org.sopt.and.dto.RequestLoginData -import org.sopt.and.dto.RequestUserRegistrationData -import org.sopt.and.dto.ResponseUserRegistration +import org.sopt.and.data.api.HobbyService +import org.sopt.and.data.api.LoginService +import org.sopt.and.data.api.UserRegistrationService +import org.sopt.and.data.api.dto.RequestLoginData +import org.sopt.and.data.api.dto.RequestUserRegistrationData +import org.sopt.and.data.api.dto.ResponseUserRegistration import javax.inject.Inject @HiltViewModel