Skip to content

Commit

Permalink
[FEAT/#66] 로그인 api 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seongh06 committed Oct 3, 2024
1 parent b141501 commit 32726b2
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import okhttp3.RequestBody
import umc.everyones.lck.data.dto.BaseResponse
import umc.everyones.lck.data.dto.request.login.CommonLoginRequestDto
import umc.everyones.lck.data.dto.request.login.NicknameAuthUserRequestDto
import umc.everyones.lck.data.dto.response.login.CommonLoginResponseDto
import umc.everyones.lck.data.dto.request.login.RefreshAuthUserRequestDto
import umc.everyones.lck.data.dto.response.login.LoginResponseDto

interface LoginDataSource {
suspend fun signup(signupUserData: RequestBody, profileImage: MultipartBody.Part): BaseResponse<CommonLoginResponseDto>
suspend fun signup(signupUserData: RequestBody, profileImage: MultipartBody.Part): BaseResponse<LoginResponseDto>

suspend fun login(requestDto: CommonLoginRequestDto): BaseResponse<LoginResponseDto>

suspend fun refresh(requestDto: CommonLoginRequestDto): BaseResponse<CommonLoginResponseDto>
suspend fun refresh(requestDto: RefreshAuthUserRequestDto): BaseResponse<LoginResponseDto>

suspend fun nickname(request: NicknameAuthUserRequestDto): BaseResponse<Boolean>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package umc.everyones.lck.data.datasourceImpl

import android.util.Log
import okhttp3.MultipartBody
import okhttp3.RequestBody
import umc.everyones.lck.data.datasource.login.LoginDataSource
import umc.everyones.lck.data.dto.BaseResponse
import umc.everyones.lck.data.dto.request.login.CommonLoginRequestDto
import umc.everyones.lck.data.dto.request.login.NicknameAuthUserRequestDto
import umc.everyones.lck.data.dto.response.login.CommonLoginResponseDto
import umc.everyones.lck.data.dto.request.login.RefreshAuthUserRequestDto
import umc.everyones.lck.data.dto.response.login.LoginResponseDto
import umc.everyones.lck.data.service.LoginService
import javax.inject.Inject
Expand All @@ -18,12 +17,12 @@ class LoginDataSourceImpl @Inject constructor(
override suspend fun signup(
signupUserData: RequestBody,
profileImage: MultipartBody.Part
): BaseResponse<CommonLoginResponseDto> =
): BaseResponse<LoginResponseDto> =
loginService.signup(signupUserData, profileImage)

override suspend fun login(requestDto: CommonLoginRequestDto):BaseResponse<LoginResponseDto> = loginService.login(requestDto)

override suspend fun refresh(requestDto: CommonLoginRequestDto):BaseResponse<CommonLoginResponseDto> = loginService.refresh(requestDto)
override suspend fun refresh(requestDto: RefreshAuthUserRequestDto):BaseResponse<LoginResponseDto> = loginService.refresh(requestDto)

override suspend fun nickname(requestDto: NicknameAuthUserRequestDto): BaseResponse<Boolean> = loginService.nickname(requestDto.nickName)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package umc.everyones.lck.data.dto.request.login

data class RefreshAuthUserRequestDto(
val kakaoUserId: String,
val refreshToken: String
)

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ data class LoginResponseDto(
){
fun toLoginResponseDto() =
LoginResponseModel(accessToken, refreshToken, accessTokenExpirationTime, refreshTokenExpirationTime, nickName)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package umc.everyones.lck.data.repositoryImpl.login
import okhttp3.MultipartBody
import okhttp3.RequestBody
import umc.everyones.lck.data.datasource.login.LoginDataSource
import umc.everyones.lck.data.dto.BaseResponse
import umc.everyones.lck.domain.model.request.login.CommonLoginRequestModel
import umc.everyones.lck.domain.model.request.login.NicknameAuthUserRequestModel
import umc.everyones.lck.domain.model.response.login.CommonLoginResponseModel
import umc.everyones.lck.domain.model.request.login.RefreshAuthUserRequestModel
import umc.everyones.lck.domain.model.response.login.LoginResponseModel
import umc.everyones.lck.domain.repository.login.LoginRepository
import javax.inject.Inject
Expand All @@ -17,14 +16,14 @@ class LoginRepositoryImpl @Inject constructor(
override suspend fun signup(
signupUserData: RequestBody,
profileImage: MultipartBody.Part
): Result<CommonLoginResponseModel> =
runCatching { loginDataSource.signup(signupUserData, profileImage).data.toCommonLoginResponseDto() }
): Result<LoginResponseModel> =
runCatching { loginDataSource.signup(signupUserData, profileImage).data.toLoginResponseDto() }

override suspend fun login(request:CommonLoginRequestModel): Result<LoginResponseModel> =
runCatching { loginDataSource.login(request.toCommonLoginRequestDto()).data.toLoginResponseDto()}

override suspend fun refresh(request: CommonLoginRequestModel): Result<CommonLoginResponseModel> =
runCatching { loginDataSource.refresh(request.toCommonLoginRequestDto()).data.toCommonLoginResponseDto() }
override suspend fun refresh(request: RefreshAuthUserRequestModel): Result<LoginResponseModel> =
runCatching { loginDataSource.refresh(request.toRefreshAuthUserRequestDto()).data.toLoginResponseDto() }

override suspend fun nickname(request: NicknameAuthUserRequestModel): Result<Boolean> =
runCatching {loginDataSource.nickname(request.toNicknameAuthUserRequestDto()).data}
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/java/umc/everyones/lck/data/service/LoginService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.GET
import retrofit2.http.Header
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part
import retrofit2.http.Path
import retrofit2.http.Query
import umc.everyones.lck.data.dto.BaseResponse
import umc.everyones.lck.data.dto.request.login.CommonLoginRequestDto
import umc.everyones.lck.data.dto.request.login.NicknameAuthUserRequestDto
import umc.everyones.lck.data.dto.response.login.CommonLoginResponseDto
import umc.everyones.lck.data.dto.request.login.RefreshAuthUserRequestDto
import umc.everyones.lck.data.dto.response.login.LoginResponseDto

interface LoginService {
Expand All @@ -23,7 +20,7 @@ interface LoginService {
suspend fun signup(
@Part("signupUserData") signupUserData: RequestBody,
@Part profileImage: MultipartBody.Part
): BaseResponse<CommonLoginResponseDto>
): BaseResponse<LoginResponseDto>

@POST("/auth/login")
suspend fun login(
Expand All @@ -32,8 +29,8 @@ interface LoginService {

@POST("/auth/refresh")
suspend fun refresh(
@Body request: CommonLoginRequestDto
):BaseResponse<CommonLoginResponseDto>
@Body request: RefreshAuthUserRequestDto
):BaseResponse<LoginResponseDto>

@GET("auth/nickname")
suspend fun nickname(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ interface MypageService {
suspend fun updateTeam(
@Body request: UpdateTeamRequestDto
): BaseResponse<Boolean>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package umc.everyones.lck.domain.model.request.login

import umc.everyones.lck.data.dto.request.login.CommonLoginRequestDto
import umc.everyones.lck.data.dto.request.login.RefreshAuthUserRequestDto
import java.io.Serializable

data class RefreshAuthUserRequestModel(
val kakaoUserId: String,
val refreshToken: String
):Serializable {
fun toRefreshAuthUserRequestDto() =
RefreshAuthUserRequestDto(kakaoUserId, refreshToken)
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ package umc.everyones.lck.domain.repository.login

import okhttp3.MultipartBody
import okhttp3.RequestBody
import umc.everyones.lck.data.dto.BaseResponse
import umc.everyones.lck.data.dto.response.login.CommonLoginResponseDto
import umc.everyones.lck.domain.model.request.login.CommonLoginRequestModel
import umc.everyones.lck.domain.model.request.login.NicknameAuthUserRequestModel
import umc.everyones.lck.domain.model.response.login.CommonLoginResponseModel
import umc.everyones.lck.domain.model.request.login.RefreshAuthUserRequestModel
import umc.everyones.lck.domain.model.response.login.LoginResponseModel

interface LoginRepository {
suspend fun signup(signupUserData:RequestBody, profileImage: MultipartBody.Part): Result<CommonLoginResponseModel>
suspend fun signup(signupUserData:RequestBody, profileImage: MultipartBody.Part): Result<LoginResponseModel>

suspend fun login(request: CommonLoginRequestModel): Result<LoginResponseModel>

suspend fun refresh(request: CommonLoginRequestModel): Result<CommonLoginResponseModel>
suspend fun refresh(request: RefreshAuthUserRequestModel): Result<LoginResponseModel>

suspend fun nickname(request: NicknameAuthUserRequestModel): Result<Boolean>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package umc.everyones.lck.presentation.login

import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.kakao.sdk.common.model.ClientError
Expand All @@ -12,7 +11,6 @@ import dagger.hilt.android.AndroidEntryPoint
import timber.log.Timber
import umc.everyones.lck.R
import umc.everyones.lck.databinding.FragmentLoginBinding
import umc.everyones.lck.domain.model.response.login.CommonLoginResponseModel
import umc.everyones.lck.domain.model.response.login.LoginResponseModel
import umc.everyones.lck.presentation.MainActivity
import umc.everyones.lck.presentation.base.BaseFragment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ package umc.everyones.lck.presentation.mypage
import androidx.navigation.fragment.findNavController
import dagger.hilt.android.AndroidEntryPoint
import umc.everyones.lck.R
import umc.everyones.lck.databinding.FragmentMypageInformationBinding
import umc.everyones.lck.databinding.FragmentMypageInformationTosAgree1Binding
import umc.everyones.lck.databinding.FragmentMypageProfileBinding
import umc.everyones.lck.presentation.base.BaseFragment
import umc.everyones.lck.util.extension.setOnSingleClickListener

Expand Down

0 comments on commit 32726b2

Please sign in to comment.