From fe87207ce2c947351590f64b511ea0d9145b5d53 Mon Sep 17 00:00:00 2001 From: kangyein9892 Date: Fri, 15 Nov 2024 16:17:59 +0900 Subject: [PATCH] =?UTF-8?q?chore/#8:=20request,=20response=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/sopt/and/data/datasource/UserDataSource.kt | 4 ++-- .../org/sopt/and/data/dto/{response => }/BaseResponse.kt | 2 +- .../dto/request/{SignUpRequest.kt => SignUpRequestDto.kt} | 4 ++-- .../response/{SignUpResponse.kt => SignUpResponseDto.kt} | 8 ++++---- .../org/sopt/and/data/repository/UserRepositoryImpl.kt | 4 ++-- .../main/java/org/sopt/and/data/service/UserService.kt | 6 +++--- .../sopt/and/domain/model/{SignUp.kt => SignUpRequest.kt} | 2 +- .../java/org/sopt/and/domain/repository/UserRepository.kt | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) rename data/src/main/java/org/sopt/and/data/dto/{response => }/BaseResponse.kt (74%) rename data/src/main/java/org/sopt/and/data/dto/request/{SignUpRequest.kt => SignUpRequestDto.kt} (79%) rename data/src/main/java/org/sopt/and/data/dto/response/{SignUpResponse.kt => SignUpResponseDto.kt} (60%) rename domain/src/main/java/org/sopt/and/domain/model/{SignUp.kt => SignUpRequest.kt} (70%) diff --git a/data/src/main/java/org/sopt/and/data/datasource/UserDataSource.kt b/data/src/main/java/org/sopt/and/data/datasource/UserDataSource.kt index 03fcedc..1ce60a0 100644 --- a/data/src/main/java/org/sopt/and/data/datasource/UserDataSource.kt +++ b/data/src/main/java/org/sopt/and/data/datasource/UserDataSource.kt @@ -7,7 +7,7 @@ import org.sopt.and.data.di.UserSharedPreference import org.sopt.and.data.dto.request.SignUpRequest import org.sopt.and.data.service.UserService import org.sopt.and.domain.exception.Result -import org.sopt.and.domain.model.SignUp +import org.sopt.and.domain.model.SignUpRequest internal class UserDataSource @Inject constructor( @UserSharedPreference private val userSharedPreference: SharedPreferences, @@ -28,7 +28,7 @@ internal class UserDataSource @Inject constructor( userSharedPreference.edit().clear().apply() } - suspend fun signUp(request: SignUpRequest): Result = execute { + suspend fun signUp(request: SignUpRequest): Result = execute { userService.signUp(request).result.toDomainModel() } diff --git a/data/src/main/java/org/sopt/and/data/dto/response/BaseResponse.kt b/data/src/main/java/org/sopt/and/data/dto/BaseResponse.kt similarity index 74% rename from data/src/main/java/org/sopt/and/data/dto/response/BaseResponse.kt rename to data/src/main/java/org/sopt/and/data/dto/BaseResponse.kt index f30159c..29dfc97 100644 --- a/data/src/main/java/org/sopt/and/data/dto/response/BaseResponse.kt +++ b/data/src/main/java/org/sopt/and/data/dto/BaseResponse.kt @@ -1,4 +1,4 @@ -package org.sopt.and.data.dto.response +package org.sopt.and.data.dto import kotlinx.serialization.Serializable diff --git a/data/src/main/java/org/sopt/and/data/dto/request/SignUpRequest.kt b/data/src/main/java/org/sopt/and/data/dto/request/SignUpRequestDto.kt similarity index 79% rename from data/src/main/java/org/sopt/and/data/dto/request/SignUpRequest.kt rename to data/src/main/java/org/sopt/and/data/dto/request/SignUpRequestDto.kt index 34971ed..1e109dc 100644 --- a/data/src/main/java/org/sopt/and/data/dto/request/SignUpRequest.kt +++ b/data/src/main/java/org/sopt/and/data/dto/request/SignUpRequestDto.kt @@ -4,13 +4,13 @@ import kotlinx.serialization.Serializable import org.sopt.and.domain.model.User @Serializable -data class SignUpRequest( +internal data class SignUpRequest( val hobby: String, val password: String, val username: String ) -fun User.toRequestBody(): SignUpRequest { +internal fun User.toRequestBody(): SignUpRequest { return SignUpRequest( hobby = hobby, password = password, diff --git a/data/src/main/java/org/sopt/and/data/dto/response/SignUpResponse.kt b/data/src/main/java/org/sopt/and/data/dto/response/SignUpResponseDto.kt similarity index 60% rename from data/src/main/java/org/sopt/and/data/dto/response/SignUpResponse.kt rename to data/src/main/java/org/sopt/and/data/dto/response/SignUpResponseDto.kt index d59b6b7..93f3cdd 100644 --- a/data/src/main/java/org/sopt/and/data/dto/response/SignUpResponse.kt +++ b/data/src/main/java/org/sopt/and/data/dto/response/SignUpResponseDto.kt @@ -2,15 +2,15 @@ package org.sopt.and.data.dto.response import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import org.sopt.and.domain.model.SignUp +import org.sopt.and.domain.model.SignUpRequest @Serializable -internal data class SignUpResponse( +internal data class SignUpResponseDto( @SerialName("no") val userNumber: Int ){ - fun toDomainModel(): SignUp { - return SignUp( + fun toDomainModel(): SignUpRequest { + return SignUpRequest( userNumber = userNumber ) } diff --git a/data/src/main/java/org/sopt/and/data/repository/UserRepositoryImpl.kt b/data/src/main/java/org/sopt/and/data/repository/UserRepositoryImpl.kt index b13c639..945d61e 100644 --- a/data/src/main/java/org/sopt/and/data/repository/UserRepositoryImpl.kt +++ b/data/src/main/java/org/sopt/and/data/repository/UserRepositoryImpl.kt @@ -3,7 +3,7 @@ package org.sopt.and.data.repository import jakarta.inject.Inject import org.sopt.and.data.datasource.UserDataSource import org.sopt.and.data.dto.request.toRequestBody -import org.sopt.and.domain.model.SignUp +import org.sopt.and.domain.model.SignUpRequest import org.sopt.and.domain.model.User import org.sopt.and.domain.repository.UserRepository import org.sopt.and.domain.exception.Result @@ -24,7 +24,7 @@ internal class UserRepositoryImpl @Inject constructor( return userDataSource.id } - override suspend fun signUp(user: User): Result { + override suspend fun signUp(user: User): Result { return userDataSource.signUp(user.toRequestBody()) } diff --git a/data/src/main/java/org/sopt/and/data/service/UserService.kt b/data/src/main/java/org/sopt/and/data/service/UserService.kt index f39af2f..949530c 100644 --- a/data/src/main/java/org/sopt/and/data/service/UserService.kt +++ b/data/src/main/java/org/sopt/and/data/service/UserService.kt @@ -1,8 +1,8 @@ package org.sopt.and.data.service import org.sopt.and.data.dto.request.SignUpRequest -import org.sopt.and.data.dto.response.BaseResponse -import org.sopt.and.data.dto.response.SignUpResponse +import org.sopt.and.data.dto.BaseResponse +import org.sopt.and.data.dto.response.SignUpResponseDto import retrofit2.http.Body import retrofit2.http.POST @@ -10,6 +10,6 @@ internal interface UserService { @POST("user") suspend fun signUp( @Body request: SignUpRequest - ): BaseResponse + ): BaseResponse } \ No newline at end of file diff --git a/domain/src/main/java/org/sopt/and/domain/model/SignUp.kt b/domain/src/main/java/org/sopt/and/domain/model/SignUpRequest.kt similarity index 70% rename from domain/src/main/java/org/sopt/and/domain/model/SignUp.kt rename to domain/src/main/java/org/sopt/and/domain/model/SignUpRequest.kt index 0a198fe..d5e35f1 100644 --- a/domain/src/main/java/org/sopt/and/domain/model/SignUp.kt +++ b/domain/src/main/java/org/sopt/and/domain/model/SignUpRequest.kt @@ -1,5 +1,5 @@ package org.sopt.and.domain.model -data class SignUp( +data class SignUpRequest( val userNumber: Int ) diff --git a/domain/src/main/java/org/sopt/and/domain/repository/UserRepository.kt b/domain/src/main/java/org/sopt/and/domain/repository/UserRepository.kt index be3aaa2..07083eb 100644 --- a/domain/src/main/java/org/sopt/and/domain/repository/UserRepository.kt +++ b/domain/src/main/java/org/sopt/and/domain/repository/UserRepository.kt @@ -1,6 +1,6 @@ package org.sopt.and.domain.repository -import org.sopt.and.domain.model.SignUp +import org.sopt.and.domain.model.SignUpRequest import org.sopt.and.domain.model.User import org.sopt.and.domain.exception.Result @@ -8,5 +8,5 @@ interface UserRepository { fun saveUser(id: String, password: String) fun clearIdPassword() fun getId(): String - suspend fun signUp(user: User): Result + suspend fun signUp(user: User): Result } \ No newline at end of file